html - (HTML & CSS) 我正在尝试在图像之间添加圆圈,但它们不会垂直居中
问题描述
所以我试图在图像之间添加一些圆圈来为我的网页添加一些样式。它们水平居中,但不是垂直居中。我希望圆圈与图像垂直居中,你知道怎么做吗?欢迎任何帮助,因为我是一名新的培训开发人员!到目前为止,我将留下我的网页图像,以及我的 HTML 和 CSS 代码。
.features {
padding: 20px;
display: flex;
flex-direction: row;
color: rgb(0, 0, 0);
}
.features figure {
margin: auto;
width: 100px;
}
.features figure{
width: 200px;
border: 1px solid rgb(117, 117, 117);
border-radius: 10px;
box-shadow: rgb(0, 0, 0) 0px 0px 5px;
text-align: center;
}
.figImg{
object-fit: contain;
width: 200px;
border-radius: 10px 10px 0 0;
}
header .logo a {
background: url("My Post.png");
display: inline-block;
width: 350px;
height: 250px;
text-indent: -99999999px;
background-repeat: no-repeat;
background-size: 350px;
position: relative;
top: -160px;
color: white;
}
.bod {
padding-left: 25px;
padding-right: 25px;
font-family: 'Lato', 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans';
}
p {
background: rgb(238, 238, 238);
border-radius: 10px;
border: 2px solid black;
padding: 10px;
box-shadow: rgb(0, 0, 0) 0px 0px 5px;
}
.dot {
height: 12px;
width: 12px;
background-color: rgb(238, 238, 238);
border-radius: 50%;
display: inline-block;
border: 2px solid black;
}
<section class="bod">
<p>Hello! :) My name is Novakron. I am an American Youtuber and Skinner. If you want to know more about me then head over to the "About Me" page! I will make you any skin that you want, and I can re-shade skins for you, if you send me the file! I have made over 50+ skins before, and have a lot of experience. I also can do anything you want for a very low price (see "Pricing" page. If you are looking for a new skin, or just an upgrade then you are in the right place! Thank you for visiting my website, and if you do decide to pick me to make you an awesome skin, then head over to the "Contact" Page! </p>
</section>
<section class="features">
<figure>
<img src="Applll.png" alt="E Girl Skin" class="figImg">
<figcaption>Apple?</figcaption>
</figure>
<span class="dot"></span>
<figure>
<img src="sterrnweell.jpg" alt="Mario Skin" class="figImg">
<figcaption>Weird Steering Wheel</figcaption>
</figure>
<span class="dot"></span>
<figure>
<img src="400xx400x.jpg" alt="E Boy Skin" class="figImg">
<figcaption>This pic is dumb</figcaption>
</figure>
</section>
解决方案
设置margin-bottom: auto
和margin-top: auto
.features {
padding: 20px;
display: flex;
flex-direction: row;
color: rgb(0, 0, 0);
}
.features figure {
margin: auto;
width: 100px;
}
.features figure{
width: 200px;
border: 1px solid rgb(117, 117, 117);
border-radius: 10px;
box-shadow: rgb(0, 0, 0) 0px 0px 5px;
text-align: center;
}
.figImg{
object-fit: contain;
width: 200px;
border-radius: 10px 10px 0 0;
}
header .logo a {
background: url("My Post.png");
display: inline-block;
width: 350px;
height: 250px;
text-indent: -99999999px;
background-repeat: no-repeat;
background-size: 350px;
position: relative;
top: -160px;
color: white;
}
.bod {
padding-left: 25px;
padding-right: 25px;
font-family: 'Lato', 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans';
}
p {
background: rgb(238, 238, 238);
border-radius: 10px;
border: 2px solid black;
padding: 10px;
box-shadow: rgb(0, 0, 0) 0px 0px 5px;
}
.dot {
height: 12px;
width: 12px;
background-color: rgb(238, 238, 238);
border-radius: 50%;
display: inline-block;
border: 2px solid black;
margin-top: auto;
margin-bottom: auto;
}
<section class="bod">
<p>Hello! :) My name is Novakron. I am an American Youtuber and Skinner. If you want to know more about me then head over to the "About Me" page! I will make you any skin that you want, and I can re-shade skins for you, if you send me the file! I have made over 50+ skins before, and have a lot of experience. I also can do anything you want for a very low price (see "Pricing" page. If you are looking for a new skin, or just an upgrade then you are in the right place! Thank you for visiting my website, and if you do decide to pick me to make you an awesome skin, then head over to the "Contact" Page! </p>
</section>
<section class="features">
<figure>
<img src="Applll.png" alt="E Girl Skin" class="figImg">
<figcaption>Apple?</figcaption>
</figure>
<span class="dot"></span>
<figure>
<img src="sterrnweell.jpg" alt="Mario Skin" class="figImg">
<figcaption>Weird Steering Wheel</figcaption>
</figure>
<span class="dot"></span>
<figure>
<img src="400xx400x.jpg" alt="E Boy Skin" class="figImg">
<figcaption>This pic is dumb</figcaption>
</figure>
</section>
只有一件小事:下次请添加最小的可重现示例:)
推荐阅读
- java - 如何使用 Java 驱动程序 3.4+ 在 mongodb 中使用 ObjectId 字段计算唯一 _id?
- python - numpy:沿两个轴的矢量化累积和
- azure-functions - 在 Docker 容器上的 Azure Function Apps Runtime 2.x 中运行 csproj 函数时,如何根据环境条件设置 AuthorzationLevel?
- spring - 是否可以在 spring elasticsearch 中使用 _update_by_query
- html - 在字段中输入文本时更改提交按钮的颜色
- vba - 如何用零值声明窗口
- jquery - jQuery ScrollTop 到元素 ID 在 Safari 上不起作用
- python-3.x - Flask-AppBuilder 等效于 SQLite WHERE 子句来过滤列数据
- ruby-on-rails - Ruby on Rails 保存模型 has_many 到 has_many 不会在构建时触发
- sql - SQL query to combine column data from multiple columns