html - 不同分辨率的 CSS 问题

标签 html css

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

我的笔记本电脑是 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/

相关文章:

html - div下的CSS多个类

javascript - 模态不起作用

javascript - 循环图像并在悬停时停止 - jQuery

javascript - jQuery 根据数据值进行选择

html - CSS Clear导致div之间的空间

html - 将所有 div 中的图像与文本左侧对齐

javascript - 在第一个 slider 的标题中隐藏 Logo 。是否可以?

javascript - 如何获取覆盖div下元素的鼠标悬停事件

html - 菜单将页面的其余部分向下推

Javascript:无法通过 for..in 循环访问对象属性