gpt4 book ai didi

html - 在左侧添加一张照片,在右侧添加 3 张照片

转载 作者:太空宇宙 更新时间:2023-11-04 05:48:46 24 4
gpt4 key购买 nike

我无法将照片与我想要的方式对齐

我正在尝试构建一个代码,我可以在左侧放置一张大照片,然后在右侧放置三张小图片(同时它们都居中对齐),但三张小图片最终会出现在底部

这是CSS

.topnews{


}

.featurednews {
text-align: center;
left: 50%;
top: 50%;
}

.featurednews img {

width: 700px;
height: 400px;
padding: 10px;
border: 1px solid #233988;
position: ralative;
left: 50%;
top: 50%;
}

.otherfeaturednews{
text-align: center;
}

.otherfeaturednews img{
display: inline-block;
width: 200px;
height: 100px;
padding: 6px;
position: relative;
float: center;
}
<pre>
<code>
<html>
<div class="topnews">
<div class="featurednews"><img src="https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="random image"></div>
<div class="otherfeaturednews"><img src="https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="image at the side">
<div class="otherfeaturednews"><img src="https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="image at the side">
<div class="otherfeaturednews"><img src="https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="image at the side">
</div>
</div>
</div>
</div>
</html>

页面的左中应该有一张大照片,右中有三张小图片。请帮忙。我试过很多方法,但就是不管用。

是这样显示的 What I have done

它应该是这样的。 how I want it to look like

最佳答案

首先,您的 div 很乱。然后应该向 topnews div 添加一个 display flex 以并排放置每个单独的 div 容器

.topnews{
width: 100%;
display: flex;
justify-content: space-between;
height: 450px;
}

.featurednews {
width: 75%;
height: 100%;
}

.featurednews img {
width: 100%;
height: 100%;
}

.otherfeaturednews{
text-align: center;
display: flex;
flex-direction: column;
width: 20%;
height: 100%;
}
.otherfeaturednews .otherfeaturednewsimages{
height: 150px;;
margin: 10px;
}
.otherfeaturednewsimages img{
display: inline-block;
width: 100%;
height: 100%;
}
<div class="topnews">
<div class="featurednews"><img
src="https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
alt="random image">
</div>
<div class="otherfeaturednews">

<div class="otherfeaturednewsimages">
<img src="https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
alt="image at the side">
</div>
<div class="otherfeaturednewsimages">
<img src="https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
alt="image at the side">
</div>
<div class="otherfeaturednewsimages">
<img src="https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
alt="image at the side">
</div>
</div>
</div>

关于html - 在左侧添加一张照片,在右侧添加 3 张照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58468833/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com