html - 文章底部的文字
问题描述
我试图在图像旁边放一些文字,但是当我在图像之后放置文字时,它会下降并且不会停留在文章的顶部。
* {
margin: 0;
box-sizing: border-box;
}
* a:link {
text-decoration: none;
}
body {
background-color: #f5f5f5;
height: 100%;
min-height: 100%;
}
article{
background-color: #ffffff;
width: 85%;
padding: 10px 15px;
text-align: right;
direction: rtl;
border-radius: 3px;
margin: 20px auto;
-webkit-box-shadow: 0px 0px 4px -1px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 4px -1px rgba(0,0,0,0.75);
box-shadow: 0px 0px 4px -1px rgba(0,0,0,0.75);
}
img{
border: 1px solid #d9d9d9;
display: inline-block;
}
.name{
display: inline-block;
}
<body>
<article>
<img src="https://sn56.scholastic.com/content/dam/classroom-magazines/sn56/issues/2018-19/040819/picture-this-nature-s-night-light/SN56_040819_Aurora-Hero-Mobile.jpg" width="375" height="375">
<div class="name">text</div>
</article>
</body
我也尝试过将显示器用作内联,但它不起作用。
解决方案
你可以设置
article{
display: flex;
}
* {
margin: 0;
font-family: Iransans;
box-sizing: border-box;
}
* a:link {
text-decoration: none;
}
body {
background-color: #f5f5f5;
height: 100%;
min-height: 100%;
}
article{
background-color: #ffffff;
width: 85%;
padding: 10px 15px;
text-align: right;
direction: rtl;
border-radius: 3px;
margin: 20px auto;
-webkit-box-shadow: 0px 0px 4px -1px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 4px -1px rgba(0,0,0,0.75);
box-shadow: 0px 0px 4px -1px rgba(0,0,0,0.75);
}
img{
border: 1px solid #d9d9d9;
display: inline-block;
}
.name{
display: inline-block;
}
article{
display: flex;
}
<body>
<article>
<img src="https://sn56.scholastic.com/content/dam/classroom-magazines/sn56/issues/2018-19/040819/picture-this-nature-s-night-light/SN56_040819_Aurora-Hero-Mobile.jpg" width="375" height="375">
<div class="name">text</div>
</article>
</body
推荐阅读
- r - 如何使用 image() 函数在 R 中绘制数据
- python - 如何在字典中分别选择第一、第二、第三和第四键
- azure - 结果文件无效。] 'C:\Agents\Build\Agent1\_work\45\s\TestResults24_59.trx' 结果格式匹配 'VSTest' 测试结果格式
- python-3.x - 有没有办法为每个循环使用不同的列表元素?
- dart - 如何获取系统导航栏的高度?
- xaml - 如何在 GridView DataTemplate 中绑定视差视图?
- bash - 将命令输出捕获到局部变量并检查错误
- java - 固定和动态调整工作线程的数量
- javascript - 如何使用 javascript 验证是否选择了 1 个单选按钮
- java - spring data jpa 选择考虑日期和时间的值