<div class="ui segment"> <div class="ui relaxed divided list" style="height: 500px; overflow: scroll;"> <div class="item" th:each="event : ${events}"> <img class="ui avatar image" style="width: 45px;height: 45px" th:src="${event.data.headerUrl}" > <div class="content"> <div class="ui teal header" th:text="${event.data.nickname}" style="display: inline-block;">小圳</div> <span style="display: inline-block;">回复了你的评论</span> <div class="description" th:text="${event.data.content}">点点关注不迷路</div> <a href="#"><span>博客标题</span></a> </div> <div class="extras" style="float: right;"> <span>2021-10-15</span> <i class="trash icon"></i> </div> </div> </div> </div> 如何设置样式不会因为内容过长而改变
时间: 2023-07-19 07:08:06 浏览: 114
你可以使用CSS的`overflow`属性来控制内容过长时的显示方式。将父元素设置为固定高度,并添加`overflow: scroll;`或`overflow: auto;`,使内容超出父元素高度时,出现滚动条而不改变样式。例如:
```css
.ui.segment {
height: 500px;
overflow: scroll;
}
```
这样,即使内容过长,也能保持相同的样式,不会因为内容溢出而改变。
相关问题
<div class="ui segment"> <div class="ui relaxed divided list" style="height: 500px; overflow: scroll;"> <div class="item" th:each="event : ${events}"> <img class="ui avatar image" style="width: 45px;height: 45px" th:src="${event.data.headerUrl}" > <div class="content"> <a class="header" th:text="${event.data.nickname}">小圳</a> <span>回复了你的评论</span> <div class="description" th:text="${event.data.content}">点点关注不迷路</div> </div> </div> </div> </div> 如何使 小圳 和 回复了你的评论 在一行啊
可以将小圳和回复了你的评论的标签都放在同一个div中,加上 "inline" 或 "inline-block" 的样式,如下所示:
```html
<div class="ui segment">
<div class="ui relaxed divided list" style="height: 500px; overflow: scroll;">
<div class="item" th:each="event : ${events}">
<img class="ui avatar image" style="width: 45px;height: 45px" th:src="${event.data.headerUrl}">
<div class="content">
<div>
<a class="header" th:text="${event.data.nickname}" style="display: inline-block;">小圳</a>
<span style="display: inline-block;">回复了你的评论</span>
</div>
<div class="description" th:text="${event.data.content}">点点关注不迷路</div>
</div>
</div>
</div>
</div>
```
这里将小圳和回复了你的评论的标签都放在了一个div中,并将这个div的样式设置为 "display: inline-block;",这样它们就能在同一行显示了。
print(response.text)出现,{"words_result":[{"words":"<title>自贝框</title>"},{"words":"</head>"},{"words":"<body>"},{"words":"<div class=\"ui three column grid\">"},{"words":"<div class=\"two wide column\"></div>"},{"words":"<div class=\"twelve wide column\">"},{"words":"<img class=\"ui image\" src=\"banner. jpg\">"},{"words":"<div class=\"ui vertical segment\">"},{"words":"<div class=\"ui seven item menu\">"},{"words":"<a href=\"#\" class=\"item\">首页</a>"},{"words":"<a href=\"#\" class=\"item\">1</a>"},{"words":"<a href=\"#\" class=\"item\">2</a>"},{"words":"<a href=\"#\" class=\"item\">3</a>"},{"words":"<a href=\"#\" class=\"item\">4</a>"},{"words":"<a href=\"#\" class=\"item\">5</a>"},{"words":"<a href=\"#\" class=\"item\">6</a>"},{"words":"</div>"},{"words":"<div class=\"ui vertical segment\">"},{"words":"</div>"},{"words":"<div class=\"ui vertical segment\">3</div>"},{"words":"<div class=\"ui vertical segment\">4</div>"},{"words":"<div class=\"ui vertical segment\">5</div>"}],"words_result_num":22,"log_id":1667739582476171051},如何 提取里面真正的内容
可以使用 Python 的 json 库来提取其中的内容。先将 response.text 转换为字典格式,然后就可以通过字典的键值对来获取需要的内容了。例如,可以通过以下代码提取网页的标题:
```python
import json
# 将 response.text 转换为字典格式
result = json.loads(response.text)
# 提取网页的标题
title = result['words_result'][0]['words']
print(title)
```
类似地,可以通过修改键值对中的索引来提取其他内容。
阅读全文