因此,我正在使用position:absolute来对齐我网站上的元素,而在其他分辨率上它看起来有所不同。我当前的分辨率是1920x1080。我有另一个分辨率为1366x768的屏幕,它看起来很糟糕。这是我第一次制作合适的网站。还有其他对齐元素的方法来避免这种情况吗?
<html>
<head>
<style>
body{
background-color:gray;
overflow:hidden;
width:1366px;
height:768px;
}
.logo{
}
.mountain{
height:75px;
position:absolute;
left:15%;
top: 2%;
}
.name{
font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", "sans serif"; font-size: 300%; font-style: normal; font-variant: normal; font-weight: 400; line-height: 26.4px;
position:absolute;
top: 0%;
left: 19.5%;
}
.navigation{
position:relative;
top: 6%;
left: 50%;
}
.f{
height:30px;
width: 30px;
border-style:solid;
border-radius: 70px;
border-width: 1.5px;
border-color: white;
top:0px;
position:absolute;
left:20%;
}
.t{
height:30px;
width: 30px;
border-style:solid;
border-radius: 70px;
border-width: 1.5px;
border-color: white;
top:0px;
position:absolute;
left:23%;
}
.g{
height:30px;
width: 30px;
border-style:solid;
border-radius: 70px;
border-width: 1.5px;
border-color: white;
top:0px;
position:absolute;
left:26%;
}
.social{
display:inline-flexbox;
position:relative;
top: 30px;
left:1000px;
}
.content{
font-family: monospace; font-size: 500%; font-style: normal; font-variant: normal; font-weight: 700; line-height: 26.4px;
color:white;
position:absolute;
top: 30%;
left: 37%;
}
.content1{
font-family: monospace; font-size: 110%; font-style: normal; font-variant: normal; font-weight: 700; line-height: 200%;
color:white;
position:absolute;
top: 43%;
left: 24%;
}
.button{
height:50px;
width:200px;
border-style: solid;
border-width: 2px;
border-radius: 70px;
border-color:white;
position:absolute;
top: 50%;
left: 42%;
}
</style>
</head>
<body>
<div class="whole">
<div class="logo">
<img class="mountain" src="img/mountain.png">
<p class="name" style="color:white;">EVEREST</p>
</div>
<div class="navigation">
<a href="" style="text-decoration: none; color:white; margin: 20px 20px 20px 20px">Features</a>
<a href="" style="text-decoration: none; color:white; margin: 20px 20px 20px 20px">Services</a>
<a href="" style="text-decoration: none; color:white; margin: 20px 20px 20px 20px">Contact us</a>
</div>
<div class="social">
<div class="f">
<a href=""><img src="img/f.png" style="height:25px;"> </a>
</div>
<div class="t">
<a href=""> <img src="img/t.jpg" style="height:25px;"> </a>
</div>
<div class="g">
<a href=""> <img src="img/g.png" style="height:25px;"> </a>
</div>
</div>
<div class="content">
<p> Hello World. </p>
</div>
<div class="content1">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
</div>
<div class="button">
<a href="" style="color:white; font-size:20px; position: absolute; top: 15px; left: 30px; text-decoration: none;"> GET STARTED </a>
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
您需要使用Media queries之类的框架,Bootstrap使用网格来创建响应式网站。
以下是媒体查询的示例:
@media (min-width: 30em) and (orientation: landscape) { ... }
下面是一个网格Bootstrap显示3个等于屏幕大小的示例的示例:
<div class="container">
<div class="row">
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
</div>
</div>