gpt4 book ai didi

css - 如何将数字向上移动以使布局更美观

转载 作者:行者123 更新时间:2023-11-28 04:18:21 30 4
gpt4 key购买 nike

我想上下移动一些图形元素,以便在我的网站上获得 3x2 表格外观。目前是 2x3,我不确定如何移动这些数字。我很乐意你们能给我的任何帮助。

这是 HTML:

<html>
<body>
<div>
<section>
<article>
<figure class="fig">
<img src="parks/arches.jpg" alt="Arches" />
<figcaption>
Arches National Park
</figcaption>
</figure>
<figure class="fig">
<img src="parks/glacier.jpg" alt="Glacier" />
<figcaption>
Glacier National Park
</figcaption>
</figure>

<figure class="fig">
<img src="parks/teton.jpg" alt="Teton" />
<figcaption>Grand Teton National Park</figcaption>
</figure>

<figure class="fig">
<img src="parks/yellowstone.jpg" alt="Yellowstone" />
<figcaption>Yellowstone National Park</figcaption>
</figure>

<figure class="fig">
<img src="parks/yosemite.jpg" alt="Yosemite" />
<figcaption>Yosemite National Park</figcaption>
</figure>

<figure class="fig">
<img src="parks/zion.jpg" alt="Zion" />
<figcaption>Zion National Park</figcaption>
</figure>

</article>
</section>

<footer>
<p>Get out and explore! &copy; 2017 <a href="#">Explore This World and Our Country and Other Stuff</a>.</p>
</footer>
</div>
<!--end wrap div-->
</body>
</html>

这是 CSS:

figure.fig{
border: 1px solid white;
width: 250px;
float: left;
margin:5px, 5px, 0, 5px;
overflow:auto;
background-color:black;



}

figure.fig img{
width:250px;
padding: 10px, 10px, 10px, 10px;

}
figure.fig figcaption
{
color: white;
margin: 5px;
text-align: center;
font-family: Times New Roman;

}

最佳答案

在您的代码中添加此更正,figure 标签 有一些默认的 margin,它在开始时设置为 0px 然后您添加了 padding 打破了 grid 是的,而不是 pixels 使用 % 如下,

figure{
margin:0;
}
.fig{
width:28%;
height:auto;
background-color:black;
float:left;
margin:2%;
overflow:hidden;
}
.fig > figcaption{
color: white;
text-align: center;
font-family: Times New Roman;
}
 <article>
<figure class="fig">
<img src="parks/arches.jpg" alt="Arches" />
<figcaption>
Arches National Park
</figcaption>
</figure>
<figure class="fig">
<img src="parks/glacier.jpg" alt="Glacier" />
<figcaption>
Glacier National Park
</figcaption>
</figure>

<figure class="fig">
<img src="parks/teton.jpg" alt="Teton" />
<figcaption>Grand Teton National Park</figcaption>
</figure>

<figure class="fig">
<img src="parks/yellowstone.jpg" alt="Yellowstone" />
<figcaption>Yellowstone National Park</figcaption>
</figure>

<figure class="fig">
<img src="parks/yosemite.jpg" alt="Yosemite" />
<figcaption>Yosemite National Park</figcaption>
</figure>

<figure class="fig">
<img src="parks/zion.jpg" alt="Zion" />
<figcaption>Zion National Park</figcaption>
</figure>

</article>
</section>

关于css - 如何将数字向上移动以使布局更美观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42358305/

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