gpt4 book ai didi

html - 如何在文本之间对齐图像?

转载 作者:行者123 更新时间:2023-11-28 09:31:08 24 4
gpt4 key购买 nike

所以我一直在处理包含文本和图像的页面。但是,我找不到将图像放在文本之间的方法。它要么留在左上角,要么仅水平居中。这是重要的代码:

<style>
body {
margin: 0;
background-image: url("rainbowbg.png");
}
div #hype {
margin-left: auto;
margin-right: auto;
display: block;
positon: relative;
}
#hypetop {
position: fixed;
top: 0;
width: 100%;
}
#hypebot {
position: fixed;
bottom: 0;
width: 100%;
}
.hypetext {
font-family: Impact, Charcoal, sans-serif;
font-size: 64px;
text-align: center;
}
</style>
<body>
<div>
<h1 class="hypetext" id="hypetop">DIRE</h1>
<img id="hype" src="DIREHYPE.png" width="224" height="224">
<h1 class="hypetext" id="hypebot">HYPPPPPPPPPPPE</h1>
</div>
</body>

如果有人知道如何让图像在文本之间居中,那就太好了。

最佳答案

您可以使用此响应式 CSS 代码。它可能对你有帮助。试试吧。我只能将 position:fixed 更改为 position:relative

Live Working Demo

HTML 代码:

<div>
<h1 class="hypetext" id="hypetop">DIRE</h1>
<img id="hype" src="http://s30.postimg.org/qnju89rkx/banner.png" width="224" height="224"/>
<h1 class="hypetext" id="hypebot">HYPPPPPPPPPPPE</h1>
</div>

CSS 代码:

body {
margin: 0;
background-image: url("rainbowbg.png");
}
div #hype {
margin:auto;
display: block;
position: relative;
margin-top:50px;
}
#hypetop {
position: relative;
top: 0;
width: 100%;
}
#hypebot {
position:relative;
bottom: 0;
width: 100%;
}
.hypetext {
font-family: Impact, Charcoal, sans-serif;
font-size: 64px;
text-align: center;
}

结果:

result

关于html - 如何在文本之间对齐图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25703046/

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