很新的网页设计,我认为这将是一个好主意,创建一个网站的基本样机,头部,段落和粘脚,以确保我有一些基础知识:)垂直和水平的div居中和高效的css
我想知道如何将.paragraph div垂直以及水平居中以及如果有任何明显的问题或效率低下,我应该知道的代码。我只是想确保我可以编写一个基本的布局而不会产生坏习惯。
所以我结束了这个CSS:
.head {
margin: auto;
height: 100%;
width: 100%;
background-color: #000;
color:white;
text-align:center;}
body {
background-color:#99C;
}
.h1 {
font-size:50px;
font-family:Georgia, "Times New Roman", Times, serif;
padding:30px;
}
.paragraph {
color:#FFF;
text-align:center;
background-color:#333;
width:35%;
margin:auto;
margin-top:165px;
padding:10px;
}
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
/* equal to footer height */
margin-bottom: -70px;
}
.wrapper:after {
content: "";
display: block;
}
.site-footer, .wrapper:after {
/* .push must be the same height as footer */
height: 70px;
}
.site-footer {
background: orange;
text-align:center;
font-family:Arial, Helvetica, sans-serif;
font-size:40px;
line-height:70px;
}
这里是它的外观:
在此先感谢!
亚当^ h
那么你的问题到底是什么?图像没有显示出问题。 –
我相信你会得到一些有用的答案,但我只想补充一点。就高效的代码而言,每个网站都有所不同。这是应该处理的主要技能,更改代码以适应每种情况。浏览器支持是一件值得考虑的事情,并确保您的代码在您希望用户使用的浏览器上正常工作。祝你好运,快乐的编码! – Omega
好,主要是我想知道在本体中垂直居中的段落div,我一直在这里和其他地方的其他帖子上四处张望,它令我感到惊讶,唯一的解决方案,我可以找到需要添加额外的容器div周围你想要居中。似乎对我很疯狂,但无论如何感谢您的帮助! –