gpt4 book ai didi

HTML 文本对齐

转载 作者:行者123 更新时间:2023-11-28 06:06:02 26 4
gpt4 key购买 nike

<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
body {
background-image: url("bg.jpg");
}
.image{
margin-top:200px;
margin-left:50px;
}
h1.tx{
margin-top:100px;
margin left: 600px;
}
<title>Company's Info</title>

</style>
</head>
<body>
<img class="image" src='about.jpg' width="450" height="300" />
<h1 class="tx">About </h1>
<h2><center>Locations</center></h2>
<p><center>No 1, Triq San Gorg, St. Julian's, Malta</center></p>
<h2><center>Contact info</center></h2>
<p><center>Telephone: +(356) 2138 4066 <br> <br>E-mail: info@badassburgers.eu</center></p>
<h2><center>Opening hours</center></h2>
<p><center>Mon - Thur: 18:00 - 23:00 <br><br> Fri - Sun: 12:00 - 00:00</center></p>

</body>
</html>

Am making a website and very new to html and css. i am trying to align text next to the image but more centered. [image] //words next to eachother. !(https://scontent-fra3-1.xx.fbcdn.net/hphotos-xfp1/v/t35.0-12/12946923_1103488123006439_2107255178_o.png?oh=015129c632edec86ecb8e0d3421059b1&oe=570731A7)

最佳答案

尝试将页面分成两列。一个用于 .image,另一个用于 .content。同时提供 display:inline-block;, max-width:50%; 这样它们在调整大小时不会中断(尽管你应该让它们一个一个地出现在另一个下面在小型设备中。使用 @media 查询)。应用 vertical-align:middle; 瞧!一切顺利。

为了简化开发过程,请使用 Bootstrap .

* {
box-sizing: border-box;
}
body {
background-image: url("bg.jpg");
margin: 0;
}
#container {
text-align: center;
}
.image {
max-width: 50%;
display: inline-block;
vertical-align: middle;
}
.image img {
max-width: 100%;
}
.content {
text-align: center;
max-width: 50%;
display: inline-block;
vertical-align: middle;
padding: 0px 20px;
}
<!DOCTYPE html>
<html lang="en-US">

<head>
<title>Company's Info</title>
</head>

<body>
<div id="container">
<div class="image">
<img src='http://i.imgur.com/bCbboKC.jpg' />
</div>
<div class="content">
<h1 class="tx">About </h1>
<h2>Locations</h2>
<p>No 1, Triq San Gorg, St. Julian's, Malta</p>
<h2>Contact info</h2>
<p>Telephone: +(356) 2138 4066
<br>
<br>E-mail: info@badassburgers.eu</p>
<h2>Opening hours</h2>
<p>Mon - Thur: 18:00 - 23:00
<br>
<br>Fri - Sun: 12:00 - 00:00</p>
</div>
</div>
</body>

</html>

关于HTML 文本对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36445691/

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