html - 如何让块图像并排 HTML?
问题描述
如果这是重复的,请原谅我,我还是 HTML 的新手,但在谷歌搜索了一段时间后我无法解决这个问题。
我正在使用 2 个块图像来显示以下内容。
但我试图让这些块像这样并排。
这是我的代码。
<div style="text-align:center;">
<div style="display:inline-block;">
<div class="wp-block-image">
<center>
<figure class="aligncenter size-full">
<a href="https://www.idashboards.com/wp-content/uploads/2020/06/IT-Service-Desk.png" target="_blank" rel="noopener">
<img loading="lazy" width="517" height="261" src="https://www.idashboards.com/wp-content/uploads/2020/06/IT-Service-Desk.png" alt="" class="wp-image-5379">
</a>
<br>
<figcaption>
<b><u><font size="+2">
<a href="https://www.idashboards.com/wp-content/uploads/2020/06/IT-Service-Desk.png">Dashboard Example 1</a>
</font size>
</b></u>
</figcaption>
</figure>
</center>
</div>
<div class="wp-block-image">
<center>
<figure class="aligncenter size-full">
<a href=https://www.geckoboard.com/uploads/CEO-dashboard-geckoboard.png " target="_blank " rel="noopener ">
<img loading="lazy " width="517 " height="261 " src="https://www.geckoboard.com/uploads/CEO-dashboard-geckoboard.png " alt=" " class="wp-image-5379 ">
</a>
<br>
<figcaption>
<b><u><font size="+2 ">
<a href="https://www.geckoboard.com/uploads/CEO-dashboard-geckoboard.png ">Dashboard Example 2</a>
</font size>
</b></u></figcaption></figure>
</center>
</div>
</div>
</div>
解决方案
<a>
我在您的一个路径中添加了一个缺少的引号并添加display: inline-block
到两个图像容器 div 中。在整页中查看片段结果以并排查看它们。
关于您关于更改图像间距的评论 - 该<figure>
标签具有以下默认 css 值:
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-right: 40px;
您可以通过各种方式覆盖此默认 css。我喜欢创建一个具有我想要的样式的类,然后将该类添加到我希望应用新的 css 值的任何元素中。
一个重要的步骤是使您的 css 选择器比默认选择器更具体。
使用更具体的规则。通过在您选择的元素之前指示一个或多个元素,规则变得更加具体并获得更高的优先级
<div style="text-align:center;">
<div style="display:inline-block;">
<div class="wp-block-image" style="display:inline-block;">
<center>
<figure class="aligncenter size-full">
<a href="https://www.idashboards.com/wp-content/uploads/2020/06/IT-Service-Desk.png" target="_blank" rel="noopener">
<img loading="lazy" width="517" height="261" src="https://www.idashboards.com/wp-content/uploads/2020/06/IT-Service-Desk.png" alt="" class="wp-image-5379">
</a>
<br>
<figcaption>
<b><u><font size="+2">
<a href="https://www.idashboards.com/wp-content/uploads/2020/06/IT-Service-Desk.png">Dashboard Example 1</a>
</font size>
</b></u>
</figcaption>
</figure>
</center>
</div>
<div class="wp-block-image" style="display:inline-block;">
<center>
<figure class="aligncenter size-full">
<a href="https://www.geckoboard.com/uploads/CEO-dashboard-geckoboard.png " target="_blank " rel="noopener ">
<img loading="lazy " width="517 " height="261 " src="https://www.geckoboard.com/uploads/CEO-dashboard-geckoboard.png " alt=" " class="wp-image-5379 ">
</a>
<br>
<figcaption>
<b><u><font size="+2 ">
<a href="https://www.geckoboard.com/uploads/CEO-dashboard-geckoboard.png ">Dashboard Example 2</a>
</font size>
</b></u>
</figcaption>
</figure>
</center>
</div>
</div>
</div>
推荐阅读
- html - 我应该如何为课堂赋予动态风格?
- django - 在分支中重命名模型会导致所有其他分支失败
- html - 具有剪辑路径的元素中的水平(子)像素间隙
- spring-mvc - spring mvc中的简单图片上传
- python - Create an n-ary tree in python with user giving edges
- php - PHP如何在标题重定向到另一个页面之前回显警报
- java - 如何使用java并行化将rdd保存到cassandra中的for循环?
- java - 如何在android中使用改造将图像对象发送到服务器
- javascript - TypeScript:为什么参数泛型接受不正确的参数?
- reactjs - 更新 React 以使用 Hooks