2016-05-29 62 views
1

您好,我目前正在製作一個簡單的網站,以獲得更多的HTML和CSS使用經驗,目前我在放置頭文件時存在一個簡單的問題。我試圖讓徽標和文本位於特定的位置,但不知道如何通過我的CSS技能來實現它。基本上,我有這個目前:使用CSS和HTML定位文本和圖像

Current Version

這是想什麼,我有文字與標誌格式: Photoshop version

我不確定如何得到這個格式化CSS和有一直在查找關於W3學校的信息,並已經學會了相當的但不足以讓人難以理解的事情。我可以計算出與所需版本相匹配的顏色樣式,但我無法弄清楚如何讓文本和徽標位於應該放置的位置。

這裏是CSS和HTML我迄今(很基本的):

#header { 
 
    background-color:#011836; 
 
    color:#ECE7E7; 
 
    padding-top: 5px; 
 
    padding-left: 5px; 
 
    padding-right: 5px; 
 
    padding-bottom: 5px; 
 
    line-height: .1px; 
 
} 
 
.logo{ 
 
    position: relative; 
 
    left: 5px; 
 
    top:5px; 
 
    bottom:0px; 
 
} 
 
.headerText{ 
 
    text-indent: 160px; 
 
    bottom:20px; 
 
    font-family: "Verdana"; 
 
    
 
} 
 
#nav { 
 
    line-height:30px; 
 
    background-color:#179fe8; 
 
    color:white; 
 
    height:50px; 
 
    padding: 5px; 
 
} 
 
.button{ 
 
    background-color: #179fe8; 
 
    border: none; 
 
    color: white; 
 
    padding: 15px 25px; 
 
    text-align: center; 
 
    text-decoration: none; 
 
    display: inline-block; 
 
    font-size: 12px; 
 
    margin: 4px 4px; 
 
    cursor: pointer; 
 
    -webkit-transition-duration: 0.4s; 
 
    transition-duration: 0.4s; 
 
} 
 

 
.button2:hover{ 
 
    box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19); 
 
} 
 
#section { 
 
    width:350px; 
 
    float:left; 
 
    padding:10px; 
 
} 
 
#footer { 
 
    background-color:#011836; 
 
    color:white; 
 
    font-family: "Verdana"; 
 
    clear:both; 
 
    text-align:center; 
 
    padding:5px; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
<link rel="stylesheet" type="text/css" href="stylesheet.css"> 
 
</head> 
 
<body> 
 

 
<div id="header"> 
 

 
    <img class="logo" src="http://imgur.com/O2qNi6p" alt="Clarence White Logo" width="168" height="168"> 
 

 
    <h1 class="headerText" style= "display:inline;">BIOENGINEERING CLUB </h1> 
 
    <h5 class="headerText">UNIVERSITY OF MAINE</h5> 
 
</div> 
 

 
<div id="nav"> 
 
<button href="about.html" class="button button2">ABOUT</button> 
 
<button href="projects.html" class="button button2">PROJECTS</button> 
 
<button href="resume.html" class="button button2">RESUME</button> 
 
</div> 
 

 
<div id="section"> 
 
<h2>London</h2> 
 
<p>London is the capital city of England. It is the most populous city in the United Kingdom, 
 
with a metropolitan area of over 13 million inhabitants.</p> 
 
<p>Standing on the River Thames, London has been a major settlement for two millennia, 
 
its history going back to its founding by the Romans, who named it Londinium.</p> 
 
</div> 
 

 
<div id="footer"> 
 

 
</div> 
 

 
</body> 
 
</html>

就如何更好地實現造型任何指導將是非常讚賞!請耐心等待我再次學習這一切,並感謝您的時間!

回答

1

#header { 
 
    background-color:#011836; 
 
    color:#ECE7E7; 
 
    padding: 5px; 
 
    position:relative;    /* ADDED */ 
 
} 
 
#header:after{     /* ADDED */ 
 
    content:""; 
 
    display: table; 
 
    clear:both; 
 
} 
 
.headerText{      /* CHANGED */ 
 
    position:absolute; 
 
    bottom:0; 
 
    left:200px; 
 
} 
 
.logo{ 
 
    position: relative; 
 
    float:left;     /* ADDED */ 
 
    left: 5px; 
 
    top:5px; 
 
} 
 

 
#nav { 
 
    line-height:30px; 
 
    background-color:#179fe8; 
 
    color:white; 
 
    height:50px; 
 
    padding: 5px; 
 
} 
 
.button{ 
 
    background-color: #179fe8; 
 
    border: none; 
 
    color: white; 
 
    padding: 15px 25px; 
 
    text-align: center; 
 
    text-decoration: none; 
 
    display: inline-block; 
 
    font-size: 12px; 
 
    margin: 4px 4px; 
 
    cursor: pointer; 
 
    -webkit-transition-duration: 0.4s; 
 
    transition-duration: 0.4s; 
 
} 
 

 
.button2:hover{ 
 
    box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19); 
 
} 
 
#section { 
 
    width:350px; 
 
    float:left; 
 
    padding:10px; 
 
} 
 
#footer { 
 
    background-color:#011836; 
 
    color:white; 
 
    font-family: "Verdana"; 
 
    clear:both; 
 
    text-align:center; 
 
    padding:5px; 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <link rel="stylesheet" type="text/css" href="stylesheet.css"> 
 
    </head> 
 
    <body> 
 

 
    <div id="header"> 
 

 
     <img class="logo" src="http://imgur.com/O2qNi6p" alt="Clarence White Logo" width="168" height="168"> 
 
     <div class="headerText"> <!-- CREATED AN ABSOLUTE POS. PARENT --> 
 
     <h1>BIOENGINEERING CLUB </h1> 
 
     <h5>UNIVERSITY OF MAINE</h5> 
 
     </div> 
 
    </div> 
 

 
    <div id="nav"> 
 
     <button href="about.html" class="button button2">ABOUT</button> 
 
     <button href="projects.html" class="button button2">PROJECTS</button> 
 
     <button href="resume.html" class="button button2">RESUME</button> 
 
    </div> 
 

 
    <div id="section"> 
 
     <h2>London</h2> 
 
     <p>London is the capital city of England. It is the most populous city in the United Kingdom, 
 
     with a metropolitan area of over 13 million inhabitants.</p> 
 
     <p>Standing on the River Thames, London has been a major settlement for two millennia, 
 
     its history going back to its founding by the Romans, who named it Londinium.</p> 
 
    </div> 
 

 
    <div id="footer"> 
 

 
    </div> 
 

 
    </body> 
 
</html>

+0

完美的感謝你,有一定道理,該職位將是相對的!感謝您的幫助,祝您有美好的一天! – mm19

+0

不客氣。保持良好 ;) –