gpt4 book ai didi

html - 在css中垂直对齐图像和文本

转载 作者:行者123 更新时间:2023-11-28 15:56:48 24 4
gpt4 key购买 nike

我在 fiddle 中复制了一张截图.目前,我可以复制所有内容,但图像和文本仍然需要在一列中垂直对齐

enter image description here

复制屏幕截图的 HTML 代码片段是:

<div class="achievement1">
<img class="alignleft size-full wp-image-7492" src="https://s31.postimg.cc/3nkv5hy7f/rsz_31944265_10214037958016144_5257718905849249792_n.png" alt="" width="161" height="118">
<a style="color: black;" href="https://www.businessnewsdaily.com/9928-steve-cody-the-better-software-company.html">"How I Turned $1,200 into Multi-Million Dollar Businesses"</a>
<a href="https://www.businessnewsdaily.com/">- Business News Daily</a>
</div>

我制作了一个父 div 成就类,其中放置了三个子成就 div 类。



问题陈述:我想知道我应该在 CSS 部分添加哪些 CSS 代码,以便文本出现在列中,图像出现在另一列中,如屏幕截图所示。

我尝试使用 display: inline-blockdisplay:block 但我仍然无法将图像和文本放在一列中。

最佳答案

检查它是否被大多数浏览器支持:

img {
display: block;
float: left;
clear: right;
}

.achievement3,
.achievement2,
.achievement1 {
width: 100%;
display: inline-block;
margin: 10px auto;
}
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Testing</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

</head>

<body>
<div class="achievements">
<div class="achievement1">
<img class="alignleft size-full wp-image-7492" src="https://s31.postimg.cc/3nkv5hy7f/rsz_31944265_10214037958016144_5257718905849249792_n.png" alt="" width="161" height="118"><br> <a style="color: black;" href="https://www.businessnewsdaily.com/9928-steve-cody-the-better-software-company.html">"How I Turned $1,200 into Multi-Million Dollar Businesses"</a><br> <a href="https://www.businessnewsdaily.com/">- Business News Daily</a>
</div>
<div class="achievement2">
<img class="alignleft size-full wp-image-7501" src="https://s31.postimg.cc/3nkv5hy7f/rsz_31944265_10214037958016144_5257718905849249792_n.png" alt="" width="161" height="118"><br> <a style="color: black;" href="https://www.globalfranchisemagazine.com/advice/case-study/revolutionize-your-franchising">"Revolutionize Your Franchise "</a><br> <a href="https://www.globalfranchisemagazine.com/">- Global Franchise Magazine</a>
</div>
<div class="achievement3">
<img class="alignleft size-full wp-image-7492" src="https://s31.postimg.cc/3nkv5hy7f/rsz_31944265_10214037958016144_5257718905849249792_n.png" alt="" width="161" height="118"><br> <a style="color: black;" href="https://www.businessnewsdaily.com/9928-steve-cody-the-better-software-company.html">"Introduces Franchise Community to BPro Platform"</a><br> <a href="http://www.franchiseharbor.com/">- Franchise Harbor</a>
</div>
</div>
</body>

</html>

关于html - 在css中垂直对齐图像和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50421191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com