所以我刚刚开始我的网页设计师的职业生涯,现在正在完成我的第一个项目,我刚刚完成了第一页设计,但无论如何我对css设计有一些担忧,我创建,主要是关于定位html元素。这是代码示例:
.contentbackground
{
background-image: url('../images/body/BG.png');
width: 1218px;
height: 370px;
position: absolute;
top: 205px;
margin-left: 67px;
}
.loginbox
{
width: 351px;
height: 280px;
position: absolute;
top: 40px;
right: -12px;
}
.lblLogin
{
position: absolute;
top: 85px;
right: 265px;
font-family: "Century Gothic";
font-size: 16px;
color: #FFFFFF;
}
问题是,这种方法是最佳做法吗?我的意思是,设置绝对位置,并手动配置顶部,左侧,右侧,底部位置,是否建议使用?
答案 0 :(得分:8)
我认为您不必为每个元素添加position: absolute
,这不是好事。您只能将absolute
用于特定情况。事实是,position: absolute
会在任何地方放置一个元素,它可能会不流动,并且不会影响流程中的任何其他元素或受其影响。您可以在此处详细了解定位: