html - 一些元素不使用 Bootstrap 居中
问题描述
我正在研究将在我正在构建的网站的一个页面中使用的项目。我已经成功构建了该项目,但我希望它在页面中居中并且我只能将图像居中,其余文本根本不会移动。
HTML 代码:
<article class="col-sm text-center">
<a href="https://www.google.com/">
<img style="border-radius: 5px;" width="400" height="561" src="https://i.imgur.com/kE1WrzV.png" alt="Image" loading="lazy" />
</a>
<div style="margin-top: 2%;" class="container-fluid">
<div class="row center-block">
<h6 class="style-anime-title"><a class="style-anime-a" href="{{ request.path }}{{obj.mNameEN}}">This is a test (Some more test)</a></h6>
</div>
<div class="row center-block" style="max-width:80%;">
<div>
<a href="/category/{{ cat.mCategoryName }}" class="style-anime-option style-anime-a">Category 1</a>
<i style="color: #7d7d7d;" class="style-bullets fa fa-circle"></i>
<a href="/category/{{ cat.mCategoryName }}" class="style-anime-option style-anime-a">Category 2</a>
<i style="color: #7d7d7d;" class="style-bullets fa fa-circle"></i>
<a href="/category/{{ cat.mCategoryName }}" class="style-anime-option style-anime-a">Category 3</a>
<i style="color: #7d7d7d;" class="style-bullets fa fa-circle"></i>
<a href="/category" class="style-anime-option style-anime-a">...</a>
</div>
<div>
<i style="color: #7d7d7d;" class="style-bullets fa fa-circle"></i><span class="style-anime-option">12 items</span>
</div>
</div>
</div>
</article>
</div>
CSS:
.style-anime-title {
font-family: Montserrat !important;
text-align: center !important;
}
.style-anime-a {
text-decoration: none !important;
color: #3E3E3E !important;
transition: all .3s !important;
}
.style-anime-option {
color: #7d7d7d !important;
}
.style-bullets {
font-size: 4px !important;
display: inline-block !important;
vertical-align: middle !important;
margin-left: 5px;
margin-right: 5px;
}
解决方案
我用以下代码解决了这个问题:
HTML:
<article class="col-sm text-center">
<a href="https://www.google.com/">
<img style="border-radius: 5px;" width="400" height="561" src="https://i.imgur.com/kE1WrzV.png" alt="Image" loading="lazy" />
</a>
<div style="margin-top: 2%;" class="container-fluid">
<div class="row">
<h6 class="style-anime-title"><a class="style-anime-a" href="{{ request.path }}{{obj.mNameEN}}">This is
a test (Some more test)</a></h6>
</div>
<div class="row">
<div class="col-sm">
<div>
<a href="/category/{{ cat.mCategoryName }}" class="style-anime-option style-anime-a">Category 1</a>
<i style="color: #7d7d7d;" class="style-bullets fa fa-circle"></i>
<a href="/category/{{ cat.mCategoryName }}" class="style-anime-option style-anime-a">Category 2</a>
<i style="color: #7d7d7d;" class="style-bullets fa fa-circle"></i>
<a href="/category/{{ cat.mCategoryName }}" class="style-anime-option style-anime-a">Category 3</a>
<i style="color: #7d7d7d;" class="style-bullets fa fa-circle"></i>
<a href="/category" class="style-anime-option style-anime-a">...</a>
</div>
<div>
<span class="style-anime-option">12 items</span>
</div>
</div>
</div>
</div>
</article>
CSS:
.style-anime-title {
font-family: Montserrat !important;
text-align: center !important;
margin: auto !important;
}
推荐阅读
- spring - 在 GCP 中无法访问 Spring Boot REST API
- python - 池映射没有性能提升
- java - Java:当应用程序使用 Procrun 注册为 Windows 服务时,使用 ProcessBuilder 运行批处理文件
- javascript - 如何使 clearTimeout 正常工作以取消(中断)setTimeout 循环?
- asp.net - 在具有 3 个外键的数据库中插入记录
- django - urlpatterns 的行为不符合预期
- konvajs - 有什么方法可以设置/获取 konva 形状的数据?
- python - 关于 Keras/Tensorflow 中超参数调优的问题
- c# - CRUD 的泛型类 - C# 中使用存储库和工作单元模式的依赖注入
- scala - 如何将 Some 与 mockito 中的任何值匹配