我想问如何显示图像上方的文本,并且文件位于滚动条内,如下图所示。 我搜索了谷歌和使用的位置,但它没有奏效。我希望你能帮我找到解决办法。级联样式表(CSS) - 在滚动条的图像上方创建帖子
1
A
回答
1
添加父DIV和背景设置为一个图像。然后你可以在其中添加一个子/嵌套div或标题标签。
请参阅下面的伪代码。我没有测试代码,但它应该足以让你走上正轨。
CSS
#container-img{
height: 500px; /* set the height you want the image to be */
width: 500px; /* set the width of the image */
background: url('your-img-src-here.png') no-repeat center center;
/* you can add whatever sizing and alignment after the url*/
}
#child-txt{
font-size: 14px;
font-weight: bold;
text-align: left;
padding: 5px;
}
HTML
<div id="container-img">
<div id="child-txt"> Cool Text Here! </div>
</div>
如果回答您的问题时,请务必将其标记为答案。 =)
+0
谢谢你,我会试试这个代码 –
0
首先,你必须创建一个图片和文本块。
给你块位置:相对和文本位置:绝对。
滚动条怎么样 - 这意味着你有一个容器,所有的照片,但它很小,所以你使用溢出:滚动。
在这里看到的代码示例:https://codepen.io/alex_ukr/pen/QgVzeL
body {
background-color: lightblue;
}
.main-container {
width: 450px;
height: 300px;
overflow-y: scroll;
border: 5px solid red;
background-color: white;
}
.picture-container {
display: inline-block;
width: 200px;
height: 200px;
position: relative;
}
img {
width: 200px;
height: 200px;
}
span {
position: absolute;
top: 10px;
font-size: 20px;
}
<div class="main-container">
<div class="picture-container">
<img src="https://uploads.scratch.mit.edu/users/avatars/1385/1878.png" alt="">
<span>your text</span>
</div>
<div class="picture-container">
<img src="https://uploads.scratch.mit.edu/users/avatars/1385/1878.png" alt="">
<span>your text</span>
</div>
<div class="picture-container">
<img src="https://uploads.scratch.mit.edu/users/avatars/1385/1878.png" alt="">
<span>your text</span>
</div>
<div class="picture-container">
<img src="https://uploads.scratch.mit.edu/users/avatars/1385/1878.png" alt="">
<span>your text</span>
</div>
</div>
+0
谢谢,我会试试这个代码 –
相关问题
- 1. 样式滚动条css colorbox
- 2. webkit css滚动条样式
- 3. 在CSS中指定图像高度px /%(级联样式表)
- 4. 数据表上的滚动条样式
- 5. 内联样式表级联样式表
- 6. CSS样式不'级联'?
- 7. 级联样式表浮动
- 8. 设计级联样式表(CSS)
- 9. 创建动态内联样式表
- 10. CSS滚动条样式跨浏览器
- 11. CSS,HTML或Jquery - 滚动条样式
- 12. 创建可滚动的图像列表
- 13. 滚动条样式
- 14. CSS列表样式图像
- 15. div上的CSS3滚动条样式
- 16. 过载级联样式表
- 17. CSS无法创建水平滚动条
- 18. Wordpress以编程方式创建帖子,然后在index.php上显示帖子
- 19. TextView的滚动条样式
- 20. WPF的滚动条样式
- 21. Div的“创建”滚动条
- 22. 如何使用JavaScript动态更改级联样式表(CSS)
- 23. 强制滚动条图像CSS
- 24. 在列表框内创建滚动条
- 25. 如何创建一个像iPhone上的浮动滚动条?
- 26. wpf中的滚动条样式根据以下图像
- 27. 使用图像来设置滚动条的样式?
- 28. 修复CSS表溢出和样式化滚动条[与JS斌]
- 29. 嵌入式CSS hacks vs单独的级联样式表
- 30. 如何创建成像滚动条
他们没有告诉你,在双击自动滚屏? – Tony
谷歌的“CSS图”。 (并不介意错字,我们都是书呆子) –