Title: CSS 实现文本的单行和多行溢出省略效 · Issue #130 · sisterAn/JavaScript-Algorithms · GitHub
Open Graph Title: CSS 实现文本的单行和多行溢出省略效 · Issue #130 · sisterAn/JavaScript-Algorithms
X Title: CSS 实现文本的单行和多行溢出省略效 · Issue #130 · sisterAn/JavaScript-Algorithms
Description: 单行文本 .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } overflow: hidden(文字长度超出限定宽度,则隐藏超出的内容) white-space: nowrap(设置文字在一行显示,不能换行) text-overflow: ellipsis(规定当文本溢出时,显示省略符号来代表被修剪的文本) 多行文本(css) .text { display: -webkit...
Open Graph Description: 单行文本 .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } overflow: hidden(文字长度超出限定宽度,则隐藏超出的内容) white-space: nowrap(设置文字在一行显示,不能换行) text-overflow: ellipsis(规定当文本溢出时,显示省略符号来代表被修...
X Description: 单行文本 .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } overflow: hidden(文字长度超出限定宽度,则隐藏超出的内容) white-space: nowrap(设置文字在一行显示,不能换行) text-overflow: ellipsis(规定当文本溢出时,显示省略符号来代表被修...
Opengraph URL: https://github.com/sisterAn/JavaScript-Algorithms/issues/130
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CSS 实现文本的单行和多行溢出省略效","articleBody":"**单行文本**\r\n```css\r\n.text {\r\n overflow: hidden; \r\n text-overflow: ellipsis; \r\n white-space: nowrap;\r\n}\r\n```\r\n- `overflow: hidden`(文字长度超出限定宽度,则隐藏超出的内容)\r\n- `white-space: nowrap`(设置文字在一行显示,不能换行)\r\n- `text-overflow: ellipsis`(规定当文本溢出时,显示省略符号来代表被修剪的文本)\r\n\r\n**多行文本(css)**\r\n```css\r\n.text {\r\n display: -webkit-box;\r\n overflow: hidden;\r\n -webkit-line-clamp: 2;\r\n -webkit-box-orient: vertical;\r\n text-overflow: ellipsis; \r\n}\r\n```\r\n- `-webkit-line-clamp: 2`(用来限制在一个块元素显示的文本的行数, 2 表示最多显示 2 行。 为了实现该效果,它需要组合其他的WebKit属性)\r\n- `display: -webkit-box`(和 1 结合使用,将对象作为弹性伸缩盒子模型显示 )\r\n- `-webkit-box-orient: vertical`(和 1 结合使用 ,设置或检索伸缩盒对象的子元素的排列方式 )\r\n- `overflow: hidden`(文本溢出限定的宽度就隐藏内容)\r\n- `text-overflow: ellipsis`(多行文本的情况下,用省略号“…”隐藏溢出范围的文本)\r\n\r\n**多行文本(js)**\r\n- 监听DOM尺寸变化\r\n- 判断是否溢出 scrollHeight \u003e offsetHeight\r\n- 二分查找多行截取字符临界值(算法的解法:判断字符串是否溢出,二分查找字符串溢出临界子串,控制...显示)","author":{"url":"https://github.com/sisterAn","@type":"Person","name":"sisterAn"},"datePublished":"2020-11-19T23:51:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/130/JavaScript-Algorithms/issues/130"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b83fa62e-fcc6-2753-8826-f12891a3775b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFA4:178041:EC7AA9:146C874:696A8622 |
| html-safe-nonce | d1530aa41f88e36215978f6af5b37feb122a0e04ad42f331e8f60dced4d921c0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkE0OjE3ODA0MTpFQzdBQTk6MTQ2Qzg3NDo2OTZBODYyMiIsInZpc2l0b3JfaWQiOiIyNDM3NDYxNzMyNzQ5ODE5MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9c66d77d31addf33a9579b25363629d243f4fea518e17c8e7e69eaf73196ecfc |
| hovercard-subject-tag | issue:747021941 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sisterAn/JavaScript-Algorithms/130/issue_layout |
| twitter:image | https://opengraph.githubassets.com/999f6670b09f10572b3f0572c89d81bc14d93f4486b548d1a72e34be1a7c57e9/sisterAn/JavaScript-Algorithms/issues/130 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/999f6670b09f10572b3f0572c89d81bc14d93f4486b548d1a72e34be1a7c57e9/sisterAn/JavaScript-Algorithms/issues/130 |
| og:image:alt | 单行文本 .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } overflow: hidden(文字长度超出限定宽度,则隐藏超出的内容) white-space: nowrap(设置文字在一行显示,不能换行) text-overflow: ellipsis(规定当文本溢出时,显示省略符号来代表被修... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sisterAn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 913560fa317c3c5a71e34f9b19253c9f09d02b4b958a86c2a56f4c8541116377 |
| turbo-cache-control | no-preview |
| go-import | github.com/sisterAn/JavaScript-Algorithms git https://github.com/sisterAn/JavaScript-Algorithms.git |
| octolytics-dimension-user_id | 19721451 |
| octolytics-dimension-user_login | sisterAn |
| octolytics-dimension-repository_id | 252061924 |
| octolytics-dimension-repository_nwo | sisterAn/JavaScript-Algorithms |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 252061924 |
| octolytics-dimension-repository_network_root_nwo | sisterAn/JavaScript-Algorithms |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5998c30593994bf2589055aef7b22d368a499367 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width