1

我有 3 个 li,我试图水平排列,然后在每个 li 内放置一个跨度。

跨度在 Chrome 中正确定位,但在 Firefox 中的 li 边界之外。

http://jsfiddle.net/brendan_rice/mPnCh/1/

有人可以帮忙吗?

<div id="blank-slate-steps">
   <ul>
      <li class="first">
         <h3><em>Step 1</em>Create Something</h3>
         <p>Once you have created Something Else you can Create Final Thing</p>
         <span></span>
      </li>
      <li class="second">
         <h3><em>Step 2</em>Create Something Else</h3>
         <p>Once you have created Something Else you can Create Final Thing</p>
         <span></span>
      </li>
      <li class="third">
         <h3><em>Step 3</em>Create Final Thing</h3>
         <p>Once you have created Something Else you can Create Final Thing</p>
         <span></span>
      </li>
   </ul>
</div>​

CSS

body{
padding-top: 300px;
}
#blank-slate-steps {
    background-color: #E8E8E8;
    bottom: 0;
    font-family: OpenSansCondensedBold,sans-serif;
    text-align: center;
    width: 100%;
}
#blank-slate-steps li {
    display: table-cell;
    max-width: 300px;
    padding: 40px;
    position: relative;
    width: 300px;
}
#blank-slate-steps h3 {
    font-size: 1.6em;
    margin-bottom: 0.6em;
}
#blank-slate-steps h3 em {
    color: #878787;
    float: left;
    font-size: 0.8em;
    font-style: normal;
    margin-bottom: 4px;
    text-transform: uppercase;
    width: 100%;
}
#blank-slate-steps li.second span {
    background: red url("../images/sprite/icons-grey-38.png") no-repeat scroll 0 -56px transparent;
    height: 37px;
    width: 36px;
}
#blank-slate-steps span {
background-color: red;
    display: block;
    height: 20px;
    left: -10px;
    position: absolute;
    top: 50px;
    width: 20px;
}

​</p>

4

3 回答 3

6

对空白步骤 div 使用相对位置。

#blank-slate-steps {
    background-color: #E8E8E8;
    bottom: 0;
    font-family: OpenSansCondensedBold,sans-serif;
    text-align: center;
    width: 100%;
    position: relative;
}
于 2012-11-02T17:56:13.240 回答
2

好的,我已经成功了,你可以这样做:fiddle

解释:我所做的是,我用position: relative;了,#blank-slate-steps然后position: relative;再用了div,把内容包裹在<li>里面

HTML

<div id="blank-slate-steps">
   <ul>
      <li class="first">
          <div style="position: relative;">
         <h3><em>Step 1</em>Create Something</h3>
         <p>Once you have created Something Else you can Create Final Thing</p>
         <span></span>
          </div>
      </li>
      <li class="second">
          <div style="position: relative;">
         <h3><em>Step 2</em>Create Something Else</h3>
         <p>Once you have created Something Else you can Create Final Thing</p>
         <span></span>
           </div>
      </li>
      <li class="third">
          <div style="position: relative;">
         <h3><em>Step 3</em>Create Final Thing</h3>
         <p>Once you have created Something Else you can Create Final Thing</p>
         <span></span>
          </div>
      </li>
   </ul>
</div>

CSS

body{
    padding-top: 300px;
}
#blank-slate-steps {
    background-color: #E8E8E8;
    bottom: 0;
    font-family: OpenSansCondensedBold,sans-serif;
    text-align: center;
    width: 100%;
    position: relative;
}
#blank-slate-steps li {
    display: table-cell;
    max-width: 300px;
    padding: 40px;
    width: 300px;
}
#blank-slate-steps h3 {
    font-size: 1.6em;
    margin-bottom: 0.6em;
}
#blank-slate-steps h3 em {
    color: #878787;
    float: left;
    font-size: 0.8em;
    font-style: normal;
    margin-bottom: 4px;
    text-transform: uppercase;
    width: 100%;
}
#blank-slate-steps li.second span {
    background: red url("../images/sprite/icons-grey-38.png") no-repeat scroll 0 -56px transparent;
    height: 37px;
    width: 36px;
}
#blank-slate-steps span {
    background-color: red;
    display: block;
    height: 20px;
    left: -10px;
    position: absolute;
    top: 50px;
    width: 20px;
}
于 2012-11-02T17:47:45.310 回答
1

试着把你的跨度放在第一位:

<li class="second">
     <span></span>
     <h3><em>Step 2</em>Create Something Else</h3>
     <p>Once you have created Something Else you can Create Final Thing</p>
  </li>

并将跨度放入position:relativefloat:left

于 2012-11-02T17:52:08.510 回答