gpt4 book ai didi

html - 如何让一排图片居中并在每张图片周围有边框?

转载 作者:行者123 更新时间:2023-11-28 06:37:05 24 4
gpt4 key购买 nike

我想知道如何让每张图片在页面中间居中,并在每张图片的下方连续 4 张。我们将不胜感激。感谢您的宝贵时间。

我的编码可以在下面看到:

@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,300);
body {
color: #333;
font-family: 'Open Sans', sans-serif;
font-weight: 300;
}
h1,
h1+p {
margin: 30px 15px 0;
font-weight: 300;
}
h1+p a {
color: #333;
}
h1+p a:hover {
text-decoration: none;
}
h2 {
margin: 60px 15px 0;
padding: 0;
font-weight: 300;
}
h2 span {
margin-left: 1em;
color: #aaa;
font-size: 85%;
}
.column {
margin: 15px 15px 0;
padding: 0;
}
.column:last-child {
padding-bottom: 60px;
}
.column::after {
content: '';
clear: both;
display: block;
}
.column div {
position: relative;
float: left;
width: 300px;
height: 200px;
margin: 0 0 0 25px;
padding: 0;
}
.column div:first-child {
margin-left: 0;
}
.column div span {
position: absolute;
bottom: -20px;
left: 0;
z-index: -1;
display: block;
width: 300px;
margin: 0;
padding: 0;
color: #444;
font-size: 18px;
text-decoration: none;
text-align: center;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
opacity: 0;
}
figure {
width: 300px;
height: 200px;
margin: 0;
padding: 0;
background: #fff;
overflow: hidden;
}
figure:hover+span {
bottom: -36px;
opacity: 1;
}


/* Opacity #1 */
.hover11 figure img {
opacity: 1;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.hover11 figure:hover img {
opacity: .5;
}
<div class="container">
</br>
<span class="textformat1"><center><b>Gallery</b></span></center>


<center>
<div class="hover11 column">
<div>
<figure><a class="fancybox" href="images/img1fullsize.jpg"><img src="images/10647762_1068348719862622_2085603419_n.png" alt="10647762_1068348719862622_2085603419_n" width="300" height="200"></a></figure>
<span>Hover</span>
</div>
<div>
<figure><a class="fancybox" href="images/img2fullsize.jpg"><img src="images/12325991_1059629627401198_1870410396_o.jpg" alt="12325991_1059629627401198_1870410396_o" width="300" height="200"></a></figure>

</div>
<div>
<figure><a class="fancybox" href="images/img3fullsize.jpg"><img src="images/12381186_1068348869862607_2103570970_o.jpg" alt="12381186_1068348869862607_2103570970_o" width="300" height="200"></a></figure>

</div>

<div>
<figure><a class="fancybox" href="images/img4fullsize.jpg"><img src="images/1932078_1068348593195968_1861115484_n.jpg" alt="1932078_1068348593195968_1861115484_n" width="300" height="200"></a></figure>

</div>

<div>
<figure><a class="fancybox" href="images/img5fullsize.jpg"><img src="images/img5thumbnail.jpg" alt="img5thumbnail" width="300" height="200"></a></figure>

</div>

<div>
<figure><a class="fancybox" href="images/img6fullsize.jpg"><img src="images/12404434_1068348596529301_270753597_n.jpg" alt="12404434_1068348596529301_270753597_n" width="300" height="200"></a></figure>

</div>

<div>
<figure><a class="fancybox" href="images/img7fullsize.jpg"><img src="images/12404946_1068348673195960_1063608705_o.jpg" alt="12404946_1068348673195960_1063608705_o" width="300" height="200"></a></figure>

</div>

<div>
<figure><a class="fancybox" href="images/img8fullsize.jpg"><img src="images/12405008_1068348669862627_440250682_o.jpg" alt="12405008_1068348669862627_440250682_o" width="300" height="200"></a></figure>

</div>

<div>
<figure><a class="fancybox" href="images/img9fullsize.jpg"><img src="images/12413879_10683487763195950_1758712787_o.jpg" alt="12413879_10683487763195950_1758712787_o" width="300" height="200"></a></figure>

</div>

<div>
<figure><a class="fancybox" href="images/img10fullsize.jpg"><img src="images/12358479235.jpg" alt="12358479235" width="300" height="200"></a></figure>

</div>

<div>
<figure><a class="fancybox" href="images/img11fullsize.jpg"><img src="images/124522465_1068348823195945_750893117_o.jpg" alt="124522465_1068348823195945_750893117_o" width="300" height="200"></a></figure>

</div>
</div>
</center>



<br/>

最佳答案

首先,删除 <center></center>标签,因为这些实际上很快就会从 HTML 中删除/贬值。现在有一种现代的纯 CSS 方式,你应该使用它来居中。同样适用于 <b>标签!如今,任何格式都应该使用 CSS 来完成,而不是使用像 font="" 这样的“旧式”东西。或 <center><b>width=""height="" .你不应该使用 figure任何一个。基本上 .. 我猜你是从一本非常古老的书或非常古老的教程中学习 HTML 的?这就是 HTML 在 2001 年左右的工作方式,但现在,这不再是它的编码方式,它仍然有点“工作”的唯一原因是因为浏览器在看到旧式 html 时会尝试做“兼容性”事情。由于折旧,它将在未来完全停止工作。你能告诉我你想用数字实现什么吗?我会为您重写 CSS,而不使用图形。但无论如何......在你的情况下,为了使图像居中(并解决其他问题)我已经重写了你的代码看起来像这样:

HTML

<div class="container">
<br>
<div class="textformat1 text_center">Gallery</div>

<div class="hover11 column">
<a class="fancybox" href="images/img1fullsize.jpg">
<img class="image_center figure" src="images/10647762_1068348719862622_2085603419_n.png" alt="10647762_1068348719862622_2085603419_n" ></a>
<span>Hover</span>
</div>

<div>
<a class="fancybox" href="images/img2fullsize.jpg">
<img class="image_center figure" src="images/12325991_1059629627401198_1870410396_o.jpg" alt="12325991_1059629627401198_1870410396_o">
</a>
</div>

<div>
<a class="fancybox" href="images/img3fullsize.jpg">
<img class="image_center figure" src="images/12381186_1068348869862607_2103570970_o.jpg" alt="12381186_1068348869862607_2103570970_o">
</a>
</div>

<div>
<a class="fancybox" href="images/img4fullsize.jpg">
<img class="image_center figure" src="images/1932078_1068348593195968_1861115484_n.jpg" alt="1932078_1068348593195968_1861115484_n">
</a>
</div>

<div>
<a class="fancybox" href="images/img5fullsize.jpg">
<img class="image_center figure" src="images/img5thumbnail.jpg" alt="img5thumbnail">
</a>
</div>

<div>
<a class="fancybox" href="images/img6fullsize.jpg">
<img class="image_center figure" src="images/12404434_1068348596529301_270753597_n.jpg" alt="12404434_1068348596529301_270753597_n">
</a>
</div>

<div>
<a class="fancybox" href="images/img7fullsize.jpg">
<img class="image_center figure" src="images/12404946_1068348673195960_1063608705_o.jpg" alt="12404946_1068348673195960_1063608705_o">
</a>
</div>

<div>
<a class="fancybox" href="images/img8fullsize.jpg">
<img class="image_center figure" src="images/12405008_1068348669862627_440250682_o.jpg" alt="12405008_1068348669862627_440250682_o">
</a>
</div>

<div>
<a class="fancybox" href="images/img9fullsize.jpg">
<img class="image_center figure" src="images/12413879_10683487763195950_1758712787_o.jpg" alt="12413879_10683487763195950_1758712787_o">
</a>
</div>

<div>
<a class="fancybox" href="images/img10fullsize.jpg">
<img class="image_center figure" src="images/12358479235.jpg" alt="12358479235">
</a>
</div>

<div>
<a class="fancybox" href="images/img11fullsize.jpg">
<img class="image_center figure" src="images/124522465_1068348823195945_750893117_o.jpg" alt="124522465_1068348823195945_750893117_o">
</a>
</div>


</div><!--//end container-->
<br>

CSS

.image_center {
display: block;
margin-left: auto;
margin-right: auto
}

.text_center {
text-align: center; }

.figure {
width: 300px;
height: 200px; }

.figure:hover+span {
bottom: -36px;
opacity: 1; }


/* Opacity #1 */
.hover11 figure img {
opacity: 1;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.hover11 figure:hover img {
opacity: .5;



body {
color: #333;
font-family: 'Open Sans', sans-serif;
font-weight: 300;
}
h1,
h1+p {
margin: 30px 15px 0;
font-weight: 300;
}
h1+p a {
color: #333;
}
h1+p a:hover {
text-decoration: none;
}
h2 {
margin: 60px 15px 0;
padding: 0;
font-weight: 300;
}
h2 span {
margin-left: 1em;
color: #aaa;
font-size: 85%;
}
.column {
margin: 15px 15px 0;
padding: 0;
}
.column:last-child {
padding-bottom: 60px;
}
.column::after {
content: '';
clear: both;
display: block;
}
.column div {
position: relative;
float: left;
width: 300px;
height: 200px;
margin: 0 0 0 25px;
padding: 0;
}
.column div:first-child {
margin-left: 0;
}
.column div span {
position: absolute;
bottom: -20px;
left: 0;
z-index: -1;
display: block;
width: 300px;
margin: 0;
padding: 0;
color: #444;
font-size: 18px;
text-decoration: none;
text-align: center;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
opacity: 0;
}

关于html - 如何让一排图片居中并在每张图片周围有边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34583300/

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