html - 在没有浮动的CSS中对齐网格中的多个div
问题描述
我一直在尝试设计一个由多个 div 组成的网页,其中包含网格(不是 CSS 网格)中的图像,如下所示:
<div class="some classes"> Some Text </div> <br>
<a href="somwhere">
<div class="some classes float-left">
<img src="http://someimage" height="200px" alt="An image"/> <br>
<div class="some other classes"> some image text </div>
</div>
</a>
<a href="somwhere">
<div class="some classes float-left">
<img src="http://someimage" height="200px" alt="An image"/> <br>
<div class="some other classes"> some image text </div>
</div>
</a>
... many times
<footer> some footer </footer>
使用 CSS
.float-left {
float:left;
}
而其他 CSS 类只是没有任何意义的占位符。
我不知道创建了多少这样的 div,因为它是通过构建工具根据一些可变参数自动完成的。我一直在使用float:left
它似乎适合这种情况,但只要我添加一个页脚,它就会嵌入到其他一些类中。我怀疑这是由于使用了浮点数。如果有人可以向我展示使用或不使用 float 甚至其他 CSS 工具的替代方式,那将很有帮助,但我更喜欢非 JS 解决方案和响应式解决方案。
解决方案
在 CSS 中你需要编写
.float-left {
float: left;
}
代替
.float-left:{
float: left;
}
您必须删除多余的:
.
推荐阅读
- parsing - 获取根节点的语法关系
- python-3.x - 给予 GAN 的随机噪声是否应该保持不变?
- python - 将单词与列表中任何单词的前 3 个字母匹配
- javascript - this.props.history.push 在第一次尝试时不会重定向
- python - 获取每个标签的 min max 和 avg viewcount
- javascript - 使用 jQuery 在选择框选项更改时更改输入框占位符
- c# - 将按钮添加到 ForEach 循环
- android - 如何获取资源文件的扩展名?
- c# - 如何在 asp.net MVC 中检索 @html.editorfor 的值?
- pandas - 根据条件从现有列在 Pandas 中创建新列的最有效方法