English 中文(简体)
如何将文本和制表符向相邻的导航放置在一起
原标题:how to place text and a tabbed navigation next to each other
  • 时间:2012-05-23 07:10:15
  •  标签:
  • html
  • css
  • haml

我写了 h2 内和旁边的文字, 我想显示一个制表位导航, 但标签式导航没有放在它旁边, 其位于h2以下, 如灰盒内以下图像所示 :

""https://i.sstatic.net/gUhLT.png" alt="此处输入图像描述"/ >

以下是我对 html 页面的代码:

<header>

   <h2>
     Corporate
     jobpost
   </h2>


    <div id= tabjob >

         <ul>
           <li>
              <a class= innertab selectprofile  href= #YourJobposts >Your Jobposts</a>
           </li>
           <li>
              <a class= innertab signupprofile  href= #OtherJobposts >Other Jobposts</a>
           </li>
           <li>

              <a class= innertab signupprofile  href= #Appliedfor >Applied for</a>
           </li>
         </ul>
    </div>
</header>

页眉是图像中灰色的事物。在此处,我要显示文字,该标签页眉旁边的导航,以及该按钮的角。


以下是我用于此标签导航的 CSS :

#tabjob
{
  padding-top:0px;
  padding-left:10px;
    height:0px;

}

.innertab
{
    background-color: rgba(142, 194, 218, 0.3);display: block;height: 25px;
    line-height: 30px;text-align: center;
    width: auto;float: left;font-weight: bold;
    padding-left: 8px;
    padding-right: 8px;

  text-shadow: #eee 0px 0px 2px;
}
#tabjob ul li
{
 display:block;
}
最佳回答

我已经在评论中公布了答案,只是在这里补充了答案的细节。

"http://jsfiddle.net/AMAVV/1/" rel="无跟随">DEMO在这里

您的 h2 标签和所有标题标签都是 HTML 中的块元素, 需要全部宽度 。

以便避免 h2 标签, 以获取完整的宽度, 仅在此元素中添加 {float: left} {float: left}

确保您将此样式应用到特定的 h2 上, 否则您的 HTML 就会混乱。 您是否在页面上使用了多个 h2 标签 。

< 强 > HTML

<h2 class="floatTag">Corporate jobpost</h2>
    <div id= tabjob >
         <ul>
             <li>
                <a class= innertab   href= #YourJobposts >Your Jobposts</a>
              </li>
              <li>
                <a class= innertab   href= #OtherJobposts >Other Jobposts</a>
              </li>
              <li>

                <a class= innertab   href= #Appliedfor >Applied for</a>
              </li>
          </ul>
      </div>

<强 > CSS

#tabjob
{
  padding-top:0px;
  padding-left:10px;
    height:0px;
}

.innertab
{
    background-color: rgba(142, 194, 218, 0.3);display: block;height: 25px;
    line-height: 30px;text-align: center;
    width: auto;float: left;font-weight: bold;
    padding-left: 8px;
    padding-right: 8px;

  text-shadow: #eee 0px 0px 2px;
}
#tabjob ul li
{
 display:block;
}

h2.floatTag{float:left;}
问题回答

h2 和 tabjob 使用 display: inline- block 来使用 display: inline- block :

h2, #tabjob { display: inline-block }

说明:http://dabblet.com/gist/2774902' rel=“nofollow'>http://dabblet.com/gist/2774902

ul div 是块元素,表示它们总是低于它们面前的值:

 a<div>x</div>

给您两句台词,试试看

 a<div style= display: inline >x</div>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签