围绕背景图像定位按钮
我想围绕背景图像定位多个链接按钮。这里是HTML:围绕背景图像定位按钮
<body>
<div id="background">
<div id="abt"><a href="pages/about.html" class="button-link" id="aboutus">About Us</a></div>
<div id="ofc"><a href="pages/office.html" class="button-link" id="office">Office</a></div>
<div id="staf"><a href="pages/staff.html" class="button-link" id="staff">Staff</a></div>
<div id="msg"><a href="pages/message.php" class="button-link" id="message">Message</a></div>
</div>
</body>
我想将它们放置在背景周围,以便它们保持固定。
实施例:http://jsfiddle.net/kimonante/2cvz4/1/
body {
background:url(http://www.factoryoutletstores.info/img/usa-map.gif) no-repeat;
background-attachment:fixed;
/*fix the shit*/
background-position:center;
}
.button-link {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: solid 1px #20538D;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
padding: 10px 25px;
background: #0d0f12;
color: #FFF;
font-family:arial;
font-weight:600;
display:block;
}
.button-link:hover, .button-link:focus {
background: #356094;
border: solid 1px #2A4E77;
text-decoration: none;
}
.button-link:active {
-webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
-moz-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
background: #2E5481;
border: solid 1px #203E5F;
}
a {
text-decoration:none;
color:white;
width:100px;
text-transform:uppercase;
padding-left:18px;
}
#abt {
margin-left:540px;
margin-top:200px;
}
#ofc {
margin-left:160px;
margin-top:105px;
}
#msg {
margin-left:930px;
margin-top:-240px;
}
#staf {
margin-left:360px;
margin-top:260px;
}
作为你的按钮由像素定位,则需要设置div#background
到一个固定的大小,并设置背景的div#background
代替体。
也删除背景附件。此版本的工作原理如下:http://jsfiddle.net/BTVZz/
感谢的人,但它没有帮助 – 2013-04-08 12:16:55
我添加了一个工作小提琴。只需要一些定位。 – Appleshell 2013-04-08 12:36:50
ooh谢谢他的作品:D – 2013-04-08 13:19:14
这里是否有实际问题?什么不适合你? – Floris 2013-04-08 03:03:48
这使得几乎没有意义,但我认为你正在寻找的立场:固定;不是绝对的。 – ghepting 2013-04-08 03:06:23