所以我很新的HTML/CSS,我試圖建立一個我可以放在名片上的一個漂亮的基本主頁。在我的頁面頂部,我有一個按鈕列表(不是bootstrap順便說一句),他們現在是絕對定位。 問題在於,爲了讓我的網站在不同的屏幕尺寸下更加靈活,我不希望它們那樣。 但是,從他們的屬性 (在我的測試中,我將其從.button1中刪除)刪除了絕對位置: 導致下劃線奇蹟般地出現。刪除位置:絕對神奇地使文本下劃線
這裏是當我刪除的位置會發生什麼GIF:絕對: https://gyazo.com/03e95bf02e822b544a39518b1923a7db
我會在這裏包括我的代碼,但我多麼可怕敢肯定,這是不笑。
任何幫助是很好的幫助!
HTML:
<body>
<h1 id="samsmith">Sam Smith</h1>
<div id="buttonbox">
<a href="https://www.smitty1ky.tumblr.com">
<h1 class="button1">
<div class="button1con">
Tumblr
</div>
</h1>
</a>
<a href="https://open.spotify.com/user/smitty1ky">
<h1 class="button2">
<div class="button2con">
spotify
</div>
</h1>
</a>
<a href="http://westwoodlitmag.com">
<h1 class="button3">
<div class="button3con">
WestWood
</div>
</h1>
</a>
</div>
<p id="welcome"> Welcome.</p>
<p id="student">Student at <a href="http://woodford.kyschools.us/">WCHS.</a></p>
<p id="inprogress">Coming Soon</p>
<h6 class="footer">© Samuel T Smith 2015</h6>
<script type="text/javascript">
</script>
</body>
CSS:
body {
background-image: url("http://gdurl.com/5oH1");
}
#samsmith {
font-family:Megrim;
color: rgb(236,228,217);
font-size: 100px;
margin:auto;
text-align:center;
right: 0;
left: 0;
padding-bottom: 5px;
}
.button1con {
background-image: url("http://gdurl.com/VjUJ");
margin:auto;
right:0;
left:0;
height: 35px;
width:100px;
padding-top:5;
}
.button1 {
position: absolute;
font-family:Megrim;
color: rgb(236,228,217);
font-size:25;
padding-top:0;
margin:auto;
text-align:center;
height:40px;
width:100px;
right:0;
left:0;
}
.button1:hover .button1con {background-image: url("http://gdurl.com/IWM6") }
.button1:hover {color: rgb(0,0,0); }
.button2con {
background-image: url("http://gdurl.com/VjUJ");
margin:auto;
right:0;
left:0;
height: 35px;
width:100px;
padding-top:5;
}
.button2 {
position:absolute;
font-family:Megrim;
color: rgb(236,228,217);
font-size:25;
padding-top:0;
margin:auto;
text-align:center;
height:40px;
width:100px;
right:250;
left:0;
}
.button2:hover .button2con {background-image: url("http://gdurl.com/IWM6") }
.button2:hover {color: rgb(0,0,0); }
.button3con {
background-image: url("http://gdurl.com/088x");
margin:auto;
right:0;
left:0;
height: 35px;
width:150px;
padding-top:5;
}
.button3 {
position:absolute;
font-family:Megrim;
color: rgb(236,228,217);
font-size:25;
padding-top:0;
margin:auto;
text-align:center;
height:40px;
width:100px;
right:0;
left:250;
}
.button3:hover .button3con {background-image: url("http://gdurl.com/DZaI") }
.button3:hover {color: rgb(0,0,0); }
a:link {
color: rgb(236,228,217);
}
a:visited {
color: rgb(236, 228, 217);
}
a:hover {
color: rgb(0,0,0);
background-color: rgb(236,228,217);
text-decoration: none;
}
a.buttons:link {
color: rgb(236,228,217);
text-decoration:none;
}
a.buttons:visited {
color: rgb(236,228,217);
text-decoration:none;
}
a.buttons:hover {
color: rgb(0,0,0);
text-decoration:none;
}
a.button1:link {
text-decoration:none;
}
p {
font-family:Megrim;
color: rgb(236,228,217)
}
p#welcome {
position: relative;
top:300;
font-size: 50px;
margin:auto;
text-align:center;
}
p#student {
position: relative;
top:300;
font-size: 30px;
margin:auto;
text-align:center;
}
#inprogress {
font-size: 75px;
position: relative;
margin:auto;
text-align:center;
letter-spacing: 30px;
}
.footer {
font-family: Megrim;
position: fixed;
font-size: 25px;
color: #282828;
bottom: -45;
right: 10;
}
@keyframes colors {
0% {color: white;}
50% {color: red;}
100% {color: white;}
}
#inprogress {
animation-name:colors;
animation-duration:5s;
animation-iteration-count:infinite;
}
@media only screen and (max-width: 1100px) {
#samsmith {
font-family:Megrim;
color: rgb(236,228,217);
font-size: 100px;
margin:auto;
text-align:center;
right: 0;
left: 0;
padding-bottom: 5px;
}
}
@media only screen and (max-width: 500px) {
#samsmith {
font-family:Megrim;
color: rgb(236,228,217);
font-size: 75px;
margin:auto;
text-align:center;
right: 0;
left: 0;
padding-bottom: 5px;
}
.button3con {
position:absolute;
background-image: url("http://gdurl.com/088x");
margin:auto;
right:0;
left:0;
height: 35px;
width:150px;
padding-top:5;
}
.button3 {
position:relative;
font-family:Megrim;
color: rgb(236,228,217);
font-size:25;
padding-top:0;
margin:auto;
text-align:center;
height:40px;
width:100px;
right:0;
left:-20;
top:75px;
}
.button2con {
position:absolute;
background-image: url("http://gdurl.com/VjUJ");
margin:auto;
right:0;
left:40;
height: 35px;
width:100px;
padding-top:5;
}
.button2 {
position:absolute;
font-family:Megrim;
color: rgb(236,228,217);
font-size:25;
padding-top:0;
margin:auto;
text-align:center;
height:40px;
width:100px;
right:250;
left:0;
}
.button1con {
position:absolute;
background-image: url("http://gdurl.com/VjUJ");
margin:auto;
right:0;
left:80;
height: 35px;
width:100px;
padding-top:5;
}
.button1 {
position:absolute;
font-family:Megrim;
color: rgb(236,228,217);
font-size:25;
padding-top:0;
margin:auto;
text-align:center;
height:40px;
width:100px;
right:0;
left:0;
}
}
編輯1:這也是值得一提的是,我的ID = 「buttonbox」 尚未在所有被賦予一個名稱來實現一邊,所以這可能不是問題。
編輯2:創建了一個jsfiddle,但它的超級破碎。不知道爲什麼,請告知http://jsfiddle.net/b8z9y9rr/
那是奇怪的。它可能與事實有關,我沒有從我的HTML文檔中分離出樣式表呢?我也只是意識到,我沒有包括我所有的CSS,所以即時編輯並將其扔在那裏 – Smitty1ky
我無法重現與您包含的代碼的問題。請擴展您的問題以包含足夠的代碼以重現問題。編輯帖子或將代碼添加到jsfiddle.net並提供鏈接時,您可以使用代碼段。 – wf4
現在做一個jsfiddle – Smitty1ky