如何获得一个锚点按钮以适合列出的订单标签?

时间:2017-04-26 18:04:50

标签: php css wordpress-theming html-lists anchor

我有一个锚点按钮,链接到网站上的联系页面。它位于列出的商品标签内,它正在展开标题顶部和列出的商品标签。锚点按钮目前看起来像这样:

<li><div id="contact_us">
  	<a href="/contact" class="red-bg" role="button">FREE Boiler Evaluation</a>
		</div></li>

主播按钮的CSS目前如下所示:

a.red-bg{
display: inline-block;
overflow:hidden;
padding: 0 10px;
}

但是标题的CSS看起来像这样:

.header-top {
	background: #252525;
}
.header-top a {
	line-height: 40px;
}
.header-top .header-search a.red-bg {
	padding: 0 10px;
	display: block;
}
.header-top .container {
	position: relative;
}
.header-top ul li {
	list-style: none;
}
.header-top ul {
	margin: 0;
}
.header-top ul li, .header-search {
	float: left;
	margin-left: 25px;
}
.header-top ul li a {
	color: #f5f5f5;
	display: inline-block;
}
.header-top .red-bg {
	padding: 0 10px;
}
#header_wrapper ul.social-icons {
	float: right;
}
#header_wrapper ul.social-icons li {
	float: left;
	list-style: none;
	margin: 5px;
}
#header_wrapper ul.social-icons li a {
	background: url(img/social-icons.png) no-repeat;
	width: 27px;
	height: 30px;
	display: block;
	text-decoration: none;
}
#header_wrapper ul.social-icons li.facebook a {
	background-position: 0 -40px;
}
#header_wrapper ul.social-icons li.twitter a {
	background-position: -27px -40px;
}
#header_wrapper ul.social-icons li.linkedin a {
	background-position: -55px -40px;
}
#header_wrapper ul.social-icons li.blog a {
	background-position: -84px -40px;
}
#header_wrapper .pull-right ul {
	padding: 0 10px;
}
#header_wrapper ul.social-icons {
	display: none;
}

如何让它适合列出的商品标签,以便它不会继续拉伸标题或列出的商品标签?

2 个答案:

答案 0 :(得分:0)

说您希望a适合li,意味着您需要width li的固定{。}}。

&#13;
&#13;
a.red-bg {
  display: inline-block;
  overflow: hidden;
  padding: 0 10px;
  border: 1px solid white
}

li {
  width: 100px;
  background: red;
}
&#13;
<li>
  <div id="contact_us">
    <a href="/contact" class="red-bg" role="button">FREE Boiler Evaluation</a>
    <a href="/contact" class="red-bg" role="button">FREE Boiler Evaluation</a>
    <a href="/contact" class="red-bg" role="button">FREE Boiler Evaluation</a>
    <a href="/contact" class="red-bg" role="button">FREE Boiler Evaluation</a>
    <a href="/contact" class="red-bg" role="button">FREE Boiler Evaluation</a>
    <a href="/contact" class="red-bg" role="button">FREE Boiler Evaluation</a>
  </div>
</li>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

你在里面有一个div所以我做了一个跨度,但你的代码不包括该id的样式,所以我很确定这将解决它。在内联元素中包含块元素在语义上是不正确的。

见修复:

.header-top {
	background: #252525;
}
.header-top a {
	line-height: 40px;
}
.header-top .header-search a.red-bg {
	padding: 0 10px;
	display: block;
}
.header-top .container {
	position: relative;
}
.header-top ul li {
	list-style: none;
}
.header-top ul {
	margin: 0;
}
.header-top ul li, .header-search {
	float: left;
	margin-left: 25px;
}
.header-top ul li a {
	color: #f5f5f5;
	display: inline-block;
}
.header-top .red-bg {
	padding: 0 10px;
}
#header_wrapper ul.social-icons {
	float: right;
}
#header_wrapper ul.social-icons li {
	float: left;
	list-style: none;
	margin: 5px;
}
#header_wrapper ul.social-icons li a {
	background: url(img/social-icons.png) no-repeat;
	width: 27px;
	height: 30px;
	display: block;
	text-decoration: none;
}
#header_wrapper ul.social-icons li.facebook a {
	background-position: 0 -40px;
}
#header_wrapper ul.social-icons li.twitter a {
	background-position: -27px -40px;
}
#header_wrapper ul.social-icons li.linkedin a {
	background-position: -55px -40px;
}
#header_wrapper ul.social-icons li.blog a {
	background-position: -84px -40px;
}
#header_wrapper .pull-right ul {
	padding: 0 10px;
}
#header_wrapper ul.social-icons {
	display: none;
}

a.red-bg{
display: inline-block;
background: red;
padding: 0 10px;
}
<ul>
<li><span id="contact_us">
  	<a href="/contact" class="red-bg" role="button">FREE Boiler Evaluation</a>
		</span></li>
</ul>