gpt4 book ai didi

html - 不同分辨率的 CSS 问题

转载 作者:行者123 更新时间:2023-11-28 15:46:41 25 4
gpt4 key购买 nike

我正在为我的网站创建一个基本的联系页面。我正在努力让它在不同的分辨率下看起来不错。

我的笔记本电脑是 1368x766,我的显示器是 1920x1080。

设置为 absolute 的元素在四处移动,顶部图像没有移动......所有其他元素都在移动......我很困惑:

CSS:

 body {
text-align: center;
background: url("http://i.imgur.com/JN0YSkP.png");
background-repeat: repeat;
background-position: center;
color: white;
font-family: 'Roboto', sans-serif;
padding-top: 20px;
padding-bottom: 0px;
}

p {
position: absolute;
top: 225px;
right: 410px;
font-size: 32px;
}
p2 {
position: absolute;
top: 420px;
right: 974px;
font-size: 28px;
}

p3 {
position: absolute;
top: 420px;
right: 570px;
font-size: 28px;
}

p4 {
position: absolute;
top: 420px;
right: 142px;
font-size: 28px;
}

.LI
{
display: inline-block;
position: absolute;
z-index : 2;
top: 510px;
right:1050px;
}

.CV
{
display: inline-block;
position: absolute;
z-index : 2;
top: 490px;
right: 620px;
}

.mail
{
display: inline-block;
position: absolute;
z-index : 2;
top: 510px;
right: 196px;
}

.Divider
{
position: absolute;
z-index: 1;
top: 380px;
right: 28px;
padding-bottom: 20px
}

html { -webkit-font-smoothing: antialiased; }

HTML:

<!DOCTYPE html>
<head>
<link href='http://fonts.googleapis.com/css?family=Roboto:300' rel='stylesheet' type='text/css'>
<title>Benjamin Edwards | Web Designer | West Sussex</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Benjamin Edwards is a Web Designer and IT Project Manager from West Sussex. Say hello!">
<meta name="keywords" content="benjamin, edwards, IT, project, manager, photoshop, web, designer, worthing, west sussex">
<meta name="robots" content="INDEX,FOLLOW">
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>

<img src="http://i.imgur.com/6gBN3LF.png">
<p>Hi! I’m Benjamin, a Worthing based</br>Web Designer and IT Project Manager.</p>
<p2>Connect on LinkedIN:</p2>
<div class="LI">
<a href="https://www.linkedin.com/in/benjaminedwards86">
<img src="http://i.imgur.com/KEqGBV3.png">
</a>
</div>

<p3>Download my CV:</p3>
<div class="CV">
<a href="https://www.dropbox.com/s/9jtsjxpb9xqdpdw/Benjamin%20Edwards%20-%20CV.docx?dl=1" download="benjamin-edwards-CV.doc">
<img src="http://i.imgur.com/ce0Zzgi.png">
</a>
</div>

<p4>Send me an email:</p4>
<div class="mail">
<a href="mailto:benjamin.edwards86@gmail.com">
<img src="http://i.imgur.com/KQV7Eip.png">
</a>
</div>

<div class="Divider">
<img src="http://i.imgur.com/B4TiKRT.png">
</div>

</body>

JSFiddle

最佳答案

例如,它对您来说有多简单,我创建了一个 jsfiddle: JSFiddle

HTML

<img src="http://i.imgur.com/6gBN3LF.png">
<p>Hi! I’m Benjamin, a Worthing based</br>Web Designer and IT Project Manager.</p>
<ul>
<li><h1>Connect on LinkedIN:</h1>
<a href="https://www.linkedin.com/in/benjaminedwards86">
<img src="http://i.imgur.com/KEqGBV3.png">
</a>
</li>
<li><h1>Download my CV:</h1>
<a href="https://www.dropbox.com/s/9jtsjxpb9xqdpdw/Benjamin%20Edwards%20-%20CV.docx?dl=1" download="benjamin-edwards-CV.doc">
<img src="http://i.imgur.com/ce0Zzgi.png">
</a>
</li>
<li><h1>Send me an email:</h1>
<a href="mailto:benjamin.edwards86@gmail.com">
<img src="http://i.imgur.com/KQV7Eip.png">
</a>
</li>
</ul>

CSS

body {
text-align: center;
background: url("http://i.imgur.com/JN0YSkP.png");
background-repeat: repeat;
background-position: center;
color: white;
font-family: 'Roboto', sans-serif;
min-width: 900px;
}
img {
margin: auto 20px;
}

ul {
height: 275px;
width: 80%;
margin: 10% auto;
border: 3px solid #31C2A9;
min-width: 900px;
}
ul li {
float: left;
width: 33%;
border-right: 1px solid #31C2A9;
list-style-type: none;
height: 275px;
min-width: 275px;
}
ul li:last-child {
border-right: none;
}

你摆脱了所有的 css 选择器并简化了你的代码:-)并且没有单一的绝对位置 ;-)

关于html - 不同分辨率的 CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25326048/

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