php - 如何让 anchor 按钮适合列出的订单标签?

标签 php css wordpress-theming html-lists anchor

我有一个链接到网站上联系页面的 anchor 按钮。它位于列出的元素标签内,并且正在拉伸(stretch)标题顶部和列出的元素标签。 anchor 按钮目前看起来像这样:

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

anchor 按钮的 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;
}

如何让它适合列出的元素标签,这样它就不会一直拉伸(stretch)标题或列出的元素标签?

最佳答案

您在 li 中有一个 div,所以我将其设为一个跨度,但您的代码不包含该 id 的样式,所以我很确定这会修复它。在内联元素中包含 block 元素在语义上是不正确的。

查看修复:

.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>

关于php - 如何让 anchor 按钮适合列出的订单标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43641480/

相关文章:

WordPress:创建自定义主页

php - 从远程服务器运行 PHP 代码?

php - 如何使用file_get_content获取图像数据

php - 如何在 WordPress 中设置 Widgetkit 插件的数据库?

php - 如何在我的管理页面中显示数据库

html - 使下拉菜单仅在悬停时可见

php - Wordpress 子主题与复制现有主题

php - 使用数据库、php、js 确定餐厅现在是否营业(就像 yelp 一样)

jquery - 适用于所有屏幕尺寸的 HTML 前端

css - 即使存在 lint 错误,Gulp 也符合 Sass