gpt4 book ai didi

html - 是否可以只使用 div 类来分隔常用样式,而不使用表格?

转载 作者:行者123 更新时间:2023-11-28 17:31:45 25 4
gpt4 key购买 nike

我正在尝试创建一个基本的电子邮件模板。我通过编写页眉、正文、页脚、侧边栏和主标签容器为这个电子邮件模板编写了样式。这是我的代码:

<html>

<head>

<style>

.container {
position:relative;
margin-left:auto;
margin-right:auto;
color: #000;
align-items:center;
}

.sidebar {
position:absolute;
top:402px;
bottom:0px;
left:775px;
width:180px;
background:violet;


}
.header{
min-height:400px;
width:957px;
background-color:aqua;
}

.body{
margin-top:400px;
min-height:500px;
width:732px;
background-color:light-blue;
}


.footer{
margin-top:900px;
max-height:250px;
background-color:grey;
width:732px;
}



h3
{
color:#660066;
font-family:Arial;
font-size:24px;
text-align:center;

}


p
{
font-size:12;
font-family:Arial;
color:#333;


}

a:link, a:visited,a:active
{
color:#660066;
}



table {
min-width:100px;
border:none;

}

}



}
</style>


</head>


<body>
<div class="container">
<div class="header">

<p>This div section is associated to header...</p>

</div>

<div class="sidebar">

Only side bar contents will be placed here...


</div>

<div class="body">



<h3>Sample Heading</h3>
<p>This DIV section is associated to body. This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body.

This DIV section is associated to body. This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body...This DIV section is associated to body.




</div>


<br>
</p>
<div class="footer">

This DIV section is associated to footer...

</div>
</div>


</body>


</html>

现在我正在尝试将这些整个 div 元素居中,是否可以在没有表格的情况下仅使用 div 标签来做到这一点?

谢谢泰亚布

最佳答案

.container{
width:960px; // or you can also use min-width:800
margin:0 auto;
}

如果它不起作用,请尝试删除位置。

关于html - 是否可以只使用 div 类来分隔常用样式,而不使用表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25945579/

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