[英]How do I make an 3 images with bottom information
I want to make something a bit like this我想做一些像这样的东西
But with styling但随着造型
<style>
.wrapper {
border: 10px solid #897ee6;
display: inline-block;
margin-top: 0;
background-color: #e68e7e;
}
.wrapper img {
height: 32%;
width: 32%;
grid-column: 1;
border: 5px solid #e67ee6;
display: inline-flex;
position: static;
background-size: 10px;
}
</style>
<div class="wrapper">
<img src="/home/RG/image/computerIMGedit.jpg" />
<div class="content1">
</div>
<img src="example.jpg">
<img src="example.jpg">
.content1 {
height: 300px;
background: #e3c88d;
width: 30%;
margin-left: 10px;
padding: 0;
}
</style>
But then ends up looking like this但最终看起来像这样
So I decided to see if the same thing happened with the text, and it does?所以我决定看看文本是否发生了同样的事情,它确实发生了? How can I possibly make the content look like the first image?我怎样才能使内容看起来像第一张图片?
You can use CSS-grid to your advantage你可以使用CSS-grid来发挥你的优势
An example of this could be:这方面的一个例子可能是:
.wrapper { border: 10px solid #897ee6; display: grid; background-color: #e68e7e; grid-template-columns: 1fr 1fr 1fr; grid-gap: 45px; }.wrapper div { border: 5px solid #e67ee6; }
<div class="wrapper"> <div> <img src="https://picsum.photos/200" /> <p> example text </div> <div> <img src="https://picsum.photos/200" /> <p> example text </div> <div> <img src="https://picsum.photos/200" /> <p> example text </div> </div>
Note that the 1fr
unit means 1 fraction meaning that since there's three of them each div will take up a third请注意, 1fr
单位表示 1 个分数,这意味着由于其中有三个,每个 div 将占用三分之一
I think it will do what you want.我认为它会做你想要的。 Your need make division containing image and description.您需要进行包含图像和描述的划分。 These divisions need float:left
so that they gets displayed side by side.这些分区需要float:left
以便它们并排显示。 Look into the code.查看代码。 It may help you understand more.它可能会帮助您了解更多。
div.gal { margin: 5px; border: 1px solid #ccc; float: left; width: 180px; color: #111; background: #aaa; } div.gal:hover { border: 1px solid #777; } div.gal img { width: 100%; height: auto; } div.cont { padding: 15px; text-align: center; }
<div class="gal" style="background:#faa"> <img src="https://i.stack.imgur.com/xDMSV.png" width="600" height="400"> <div class="cont">Notepad Sticky</div> </div> <div class="gal" style="background:#afa"> <img src="https://i.stack.imgur.com/xDMSV.png" width="600" height="400"> <div class="cont">Notepad Sticky</div> </div> <div class="gal" style="background:#aaf"> <img src="https://i.stack.imgur.com/xDMSV.png" width="600" height="400"> <div class="cont">Notepad Sticky</div> </div>
You can use display: flex
:您可以使用display: flex
:
.horizontal { display: flex; flex-direction: row; width: 100%; align-content: center; align-items: center; }.horizontal > div { flex:1; }
<div class="horizontal"> <div> <img src="/home/RG/image/computerIMGedit.jpg" /> <p> example text</p> </div> <div> <img src="/home/RG/image/computerIMGedit.jpg" /> <p> example text</p> </div> <div> <img src="/home/RG/image/computerIMGedit.jpg" /> <p> example text</p> </div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.