我正在尝试制作一个左边有定义的菜单和右边的链接 - 但是我无法将所有的框都变成一个链接。我可以用表格解决它,但我希望有一个更平滑的解决方案。
所以我想在线的一侧漂浮而另一侧漂浮。
这是我的CSS:
li {
margin: 0px 10px 0px 100px;
padding: 30px 5px 0px 5px;
border-bottom: 2px solid black;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
display: block;
-moz-transition: background-color .3s ease-in;
-webkit-transition: background-color .3s ease-in;
-o-transition: background-color .3s ease-in;
transition: background-color .3s ease-in;
}
li:hover {
background-color: #CCC;
-moz-transition: background-color 0.01s;
-webkit-transition: background-color 0.01s;
-o-transition: background-color 0.01s;
transition: background-color 0.01s;
}
a {
float: right;
color: black;
text-decoration: none;
}
HTML:
<ul>
<li>Blog<a href="#">#.blogspot.com</a></li>
<li>Twitter<a href="https://twitter.com/#">@#</a></li>
<li>Google+<a href="https://plus.google.com/u/0/#/posts">Google+</a></li>
<li>Contact me<a href="mailto:#@gmail.com">#@gmail.com</a></li>
</ul>
或者更好,在这里:http://jsfiddle.net/hJRdN/
答案 0 :(得分:1)
这是在jsfiddle
上完成的在js小提琴中替换html和css
<ul>
<li><a href="#">Blog<span>#.blogspot.com</span></a></li>
<li><a href="https://twitter.com/#"><span>Twitter</span>@#</a></li>
<li><a href="https://plus.google.com/u/0/#/posts">Google+<span>Google+</span></a></li>
<li><a href="mailto:#@gmail.com">Contact me<span>#@gmail.com</span></a></li>
</ul>
CSS
li {
float:left;
width:400px;
margin: 0px 10px 0px 100px;
border-bottom: 2px solid black;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
display: block;
-moz-transition: background-color .3s ease-in;
-webkit-transition: background-color .3s ease-in;
-o-transition: background-color .3s ease-in;
transition: background-color .3s ease-in;
}
li:hover {
background-color: #CCC;
-moz-transition: background-color 0.01s;
-webkit-transition: background-color 0.01s;
-o-transition: background-color 0.01s;
transition: background-color 0.01s;
}
a {
display:block;
padding: 30px 5px 0px 5px;
color: black;
text-decoration: none;
width:390px;
}
a span{ float:right}
答案 1 :(得分:0)
是否需要无序列表?如果不是,你只需使用浮动的div即可轻松实现。
<a href="#">
<div class="row">
<div class="left">blog</div><div class="right">blogspot.com</div>
</div>
</a>
<a href="#">
<div class="row">
<div class="left">twitter</div><div class="right">twitter.com</div>
</div>
</a>
和css:
.row { width: 100%; float: left; }
.row:hover { background-color: #e3e3e3; }
.left { float: left; }
.right { float: right; }
.row .left { color: #000; }
.row .right { color: #000; }