填充在Chrome中返回不同的结果

时间:2017-09-19 18:28:06

标签: css twitter-bootstrap

我有以下代码在Chrome中无法正常运行。问题在于垂直社交div。当我将鼠标悬停在g +图标上方时,底部有一个3px高的空白区域。 我尝试将填充从padding: 10px 0px 9px;更改为padding: 10px 0px 10px;并将其修复为Chrome,但在FireFox和IE中将其修改。究竟是什么造成了不一致?

@import url("https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,400italic");
  @import url("https://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css");
  body {
	padding: 60px 0px;
	background-color: rgb(220, 220, 220);
}

  .event-list {
	list-style: none;
	font-family: 'Lato', sans-serif;
	margin: 0px;
	padding: 0px;
}
.event-list > li {
	background-color: rgb(255, 255, 255);
	box-shadow: 0px 0px 5px rgb(51, 51, 51);
	box-shadow: 0px 0px 5px rgba(51, 51, 51, 0.7);
	padding: 0px;
	margin: 0px 0px 20px;
}
.event-list > li > img {
	width: 100%;
}
.event-list > li > .info {
	padding-top: 5px;
	text-align: center;
}
.event-list > li > .info > .title {
	font-size: 17pt;
	font-weight: 700;
	margin: 0px;
}
.event-list > li > .info > .desc {
	font-size: 13pt;
	font-weight: 300;
	margin: 0px;
}
.event-list > li > .info > ul,
.event-list > li > .social > ul {
	display: table;
	list-style: none;
	margin: 10px 0px 0px;
	padding: 0px;
	text-align: center;
	width:100%;
}
.event-list > li > .social > ul {
	margin: 0px;
}
.event-list > li > .info > ul > li,
.event-list > li > .social > ul > li {
	display: table-cell;
	cursor: pointer;
	color: rgb(30, 30, 30);
	font-size: 11pt;
	font-weight: 300;
      padding: 3px 0px;
}
  .event-list > li > .info > ul > li > a {
	display: block;
	width: 100%;
	color: rgb(30, 30, 30);
	text-decoration: none;
}
  .event-list > li > .social > ul > li {
      padding: 0px;
  }
  .event-list > li > .social > ul > li > a {
      padding: 3px 0px;
}
.event-list > li > .info > ul > li:hover,
.event-list > li > .social > ul > li:hover {
	color: rgb(30, 30, 30);
	background-color: rgb(200, 200, 200);
}
.facebook a,
.twitter a,
.google-plus a {
	display: block;
	width: 100%;
	color: rgb(75, 110, 168) !important;
}
.twitter a {
	color: rgb(79, 213, 248) !important;
}
.google-plus a {
	color: rgb(221, 75, 57) !important;
}
.facebook:hover a {
	color: rgb(255, 255, 255) !important;
	background-color: rgb(75, 110, 168) !important;
}
.twitter:hover a {
	color: rgb(255, 255, 255) !important;
	background-color: rgb(79, 213, 248) !important;
}
.google-plus:hover a {
	color: rgb(255, 255, 255) !important;
	background-color: rgb(221, 75, 57) !important;
}

@media (min-width: 68px) {
	.event-list > li {
		position: relative;
		display: block;
		width: 100%;
		height: 120px;
		padding: 0px;
	}
	.event-list > li > img  {
		display: inline-block;
	}
	.event-list > li > img {
		width: 120px;
		float: left;
	}
	.event-list > li > .info {
		background-color: rgb(245, 245, 245);
		overflow: hidden;
	}
	.event-list > li > img {
		width: 120px;
		height: 120px;
		padding: 0px;
		margin: 0px;
	}
	.event-list > li > .info {
		position: relative;
		height: 120px;
		text-align: left;
		padding-right: 40px;
	}
	.event-list > li > .info > .title,
	.event-list > li > .info > .desc {
		padding: 0px 10px;
	}
	.event-list > li > .info > ul {
		position: absolute;
		left: 0px;
		bottom: 0px;
	}
	.event-list > li > .social {
		position: absolute;
		top: 0px;
		right: 0px;
		display: block;
		width: 40px;
	}
      .event-list > li > .social > ul {
          border-left: 1px solid rgb(230, 230, 230);
      }
	.event-list > li > .social > ul > li {
		display: block;
          padding: 0px;
	}
	.event-list > li > .social > ul > li > a {
		display: block;
		width: 40px;
		padding: 10px 0px 9px;
	}
	.event-list > li > .info > ul{
		width: calc(100% - 40px);
	}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="col-sm-12">
      <ul class="event-list">
        <li>
          <img alt="My 24th Birthday!" src="https://farm5.staticflickr.com/4150/5045502202_1d867c8a41_q.jpg" />
          <div class="info">
            <h2 class="title">Mouse0270's 24th Birthday!</h2>
            <p class="desc">Bar Hopping in Erie, Pa.</p>
            <ul>
              <li style="width:33%;">1 <span class="glyphicon glyphicon-ok"></span></li>
              <li style="width:34%;">3 <span class="fa fa-question"></span></li>
              <li style="width:33%;">103 <span class="fa fa-envelope"></span></li>
            </ul>
          </div>
          <div class="social">
            <ul>
              <li class="facebook" style="width:33%;"><a href="#facebook"><span class="fa fa-facebook"></span></a></li>
              <li class="twitter" style="width:34%;"><a href="#twitter"><span class="fa fa-twitter"></span></a></li>
              <li class="google-plus" style="width:33%;"><a href="#google-plus"><span class="fa fa-google-plus"></span></a></li>
            </ul>
          </div>
        </li>
      </ul>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:1)

我只是在“.event-list&gt; li&gt; .social&gt; ul&gt; li”中指定了高度,并在“.event-list&gt; li&gt; .social&gt; ul&gt;中返回了填充。 li&gt; a“。

造成这个问题的原因是社交字体在chrome中的高度为14px,而在FF和IE中则为14.67,因此浏览器中有3个像素差异。

@import url("https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,400italic");
  @import url("https://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css");
  body {
	padding: 60px 0px;
	background-color: rgb(220, 220, 220);
}

  .event-list {
	list-style: none;
	font-family: 'Lato', sans-serif;
	margin: 0px;
	padding: 0px;
}
.event-list > li {
	background-color: rgb(255, 255, 255);
	box-shadow: 0px 0px 5px rgb(51, 51, 51);
	box-shadow: 0px 0px 5px rgba(51, 51, 51, 0.7);
	padding: 0px;
	margin: 0px 0px 20px;
}
.event-list > li > img {
	width: 100%;
}
.event-list > li > .info {
	padding-top: 5px;
	text-align: center;
}
.event-list > li > .info > .title {
	font-size: 17pt;
	font-weight: 700;
	margin: 0px;
}
.event-list > li > .info > .desc {
	font-size: 13pt;
	font-weight: 300;
	margin: 0px;
}
.event-list > li > .info > ul,
.event-list > li > .social > ul {
	display: table;
	list-style: none;
	margin: 10px 0px 0px;
	padding: 0px;
	text-align: center;
	width:100%;
}
.event-list > li > .social > ul {
	margin: 0px;
}
.event-list > li > .info > ul > li,
.event-list > li > .social > ul > li {
	display: table-cell;
	cursor: pointer;
	color: rgb(30, 30, 30);
	font-size: 11pt;
	font-weight: 300;
      padding: 3px 0px;
}
  .event-list > li > .info > ul > li > a {
	display: block;
	width: 100%;
	color: rgb(30, 30, 30);
	text-decoration: none;
}
  .event-list > li > .social > ul > li {
      padding: 0px;
  }
  .event-list > li > .social > ul > li > a {
      padding: 3px 0px;
}
.event-list > li > .info > ul > li:hover,
.event-list > li > .social > ul > li:hover {
	color: rgb(30, 30, 30);
	background-color: rgb(200, 200, 200);
}
.facebook a,
.twitter a,
.google-plus a {
	display: block;
	width: 100%;
	color: rgb(75, 110, 168) !important;
}
.twitter a {
	color: rgb(79, 213, 248) !important;
}
.google-plus a {
	color: rgb(221, 75, 57) !important;
}
.facebook:hover a {
	color: rgb(255, 255, 255) !important;
	background-color: rgb(75, 110, 168) !important;
}
.twitter:hover a {
	color: rgb(255, 255, 255) !important;
	background-color: rgb(79, 213, 248) !important;
}
.google-plus:hover a {
	color: rgb(255, 255, 255) !important;
	background-color: rgb(221, 75, 57) !important;
}

@media (min-width: 68px) {
	.event-list > li {
		position: relative;
		display: block;
		width: 100%;
		height: 120px;
		padding: 0px;
	}
	.event-list > li > img  {
		display: inline-block;
	}
	.event-list > li > img {
		width: 120px;
		float: left;
	}
	.event-list > li > .info {
		background-color: rgb(245, 245, 245);
		overflow: hidden;
	}
	.event-list > li > img {
		width: 120px;
		height: 120px;
		padding: 0px;
		margin: 0px;
	}
	.event-list > li > .info {
		position: relative;
		height: 120px;
		text-align: left;
		padding-right: 40px;
	}
	.event-list > li > .info > .title,
	.event-list > li > .info > .desc {
		padding: 0px 10px;
	}
	.event-list > li > .info > ul {
		position: absolute;
		left: 0px;
		bottom: 0px;
	}
	.event-list > li > .social {
		position: absolute;
		top: 0px;
		right: 0px;
		display: block;
		width: 40px;
	}
      .event-list > li > .social > ul {
          border-left: 1px solid rgb(230, 230, 230);
      }
	.event-list > li > .social > ul > li {
		display: block;
        padding: 0px;
        height: 40px;
	}
	.event-list > li > .social > ul > li > a {
		display: block;
		width: 40px;
		padding: 10px 0px 10px;
	}
	.event-list > li > .info > ul{
		width: calc(100% - 40px);
	}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="col-sm-12">
      <ul class="event-list">
        <li>
          <img alt="My 24th Birthday!" src="https://farm5.staticflickr.com/4150/5045502202_1d867c8a41_q.jpg" />
          <div class="info">
            <h2 class="title">Mouse0270's 24th Birthday!</h2>
            <p class="desc">Bar Hopping in Erie, Pa.</p>
            <ul>
              <li>1 <span class="glyphicon glyphicon-ok"></span></li>
              <li>3 <span class="fa fa-question"></span></li>
              <li>103 <span class="fa fa-envelope"></span></li>
            </ul>
          </div>
          <div class="social">
            <ul>
              <li class="facebook"><a href="#facebook"><span class="fa fa-facebook"></span></a></li>
              <li class="twitter"><a href="#twitter"><span class="fa fa-twitter"></span></a></li>
              <li class="google-plus"><a href="#google-plus"><span class="fa fa-google-plus"></span></a></li>
            </ul>
          </div>
        </li>
      </ul>
    </div>
  </div>
</div>