html - 为什么我添加的其中一张图片没有对齐?
问题描述
我想在我正在处理的网站上添加一些按钮,每个按钮都可以将您带到另一个页面。我只是使用图像并向它们添加了一个超链接,并使用浮动对齐它们。我认为可能是文本,但我不确定,因为我对使用 HTML 和 CSS 还很陌生。结果是这样的:但结果是这样 的:左边的最后一个按钮未对齐
我的 HTML 类型在这里:
* {
box-sizing: border-box;
}
body {
background: url('realheckindoggopupper.png')
}
div {
padding: 5px;
background-color: black;
box-sizing: border-box;
}
.column {
float: left;
width: 25%;
padding: 1px;
}
.row::after {
content: "";
clear: both;
display: table;
}
<div>
<body style="background-color:black">
<h1 style="color:blue;text-size:50px;">Welcome to the Mamiya Mansion!</h1>
<p style="color:white;">
This is a place where I put all my thoughts. I talk about all my different interests here, from retrogaming, to retro-anime, linguistics, and philosophy. I don't have much here yet, more is on the way (including better CSS!), <br> but these buttons
will allow you to access different parts I'm working on. </br>
</p>
</div>
<div class="row">
<div class="column">
<a href="retrostuff.html">
<img src="retrostuff.png" style="width:100%;">
</a>
</div>
<div class="column">
<a href="creations.html">
<img src="creations.png" style="width:100%;">
</a>
</div>
<div class="column">
<a href="pseudstuff.html">
<img src="pseudstuff.png" style="width:100%;">
</a>
<div class="column">
<a href="misc.html">
<img src="misc.png" style="width:200%;">
</a>
</div>
</div>
解决方案
正如 Guy Incognito 在评论中指出的那样,您的最终 div 嵌套在前一个 div 中。试试这个:
<div class="row">
<div class="column">
<a href="retrostuff.html">
<img src="retrostuff.png" style="width:100%;">
</a>
</div>
<div class="column">
<a href="creations.html">
<img src="creations.png" style="width:100%;">
</a>
</div>
<div class="column">
<a href="pseudstuff.html">
<img src="pseudstuff.png" style="width:100%;">
</a>
</div>
<div class="column">
<a href="misc.html">
<img src="misc.png" style="width:100%;">
</a>
</div>
</div>
推荐阅读
- html - Flexbox 列在 IE11 中无法正确考虑包装内容
- jenkins - Jenkins Gradle 失败,无法将缓存值写入“/home/bldadm/.gradle/daemon/4.8/registry.bin”
- perl - 如何在perl中将字节数组转换为int64
- javascript - Google Apps 脚本:如何从二维数组中删除特定字符
- javascript - Javascript 在页面加载时隐藏 div 在按钮之间切换
- php - Laravel 7 中的分页 + URL 参数
- selenium-webdriver - 使用代理 InvalidArgumentError 运行 webdriver
- mongodb - 将 2 个数组对象合并为 1 个
- c# - 如何检查是否已在 Blazor 中设置属性?
- javascript - Vue.js 将数组中的值发送到端点的问题