久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

帶有旋轉文本的垂直導航

vertical navigation with rotated text(帶有旋轉文本的垂直導航)
本文介紹了帶有旋轉文本的垂直導航的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試實現具有鏈接的垂直導航菜單,并且我已使用 css3 將鏈接文本旋轉到 270 度.我旋轉了它,因為我希望文本從下到上.問題是當我添加填充頂部時,間距不一致.你可以看到我的代碼

I am trying to achieve a vertical navigation menu which has links and I have rotated the links text to 270 degree with css3. I have rotated it because I wanted the text to be bottom to top. The problem is when I add a padding top it is getting inconsistent spacing. you can see my code here. I am unable to understand the different space being taken. I also tried giving li a height but it did not work. Please if someone could help me out. Here is my code:

HTML:

<div class="main-nav">
      <ul class="nav">
        <li><a href="#">HOME</a></li>
        <li><a href="#">METHODOLGY</a></li>
        <li><a href="#">PORTFOLIO</a></li>
        <li><a href="#">SERVICES</a></li>
        <li><a href="#">TEAM</a></li>
        <li><a href="#">CONTACT</a></li>
      </ul>
 </div>

CSS:

.rotate{
    -webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-o-transform:rotate(270deg);writing-mode:lr-tb}
html, body {
  min-height:100%;
  max-height:100%;
  height:100%;
  font-family:Oswald, sans-serif, Arial;
  font-size:14px;
  background:#fff
}
a {
  text-decoration:none
}
li {
  list-style:none
}
ul {
  padding:0;
  margin:0
}
.main-nav {
  width:45px;
  float:left;
  height:100%;
  position:fixed;
  background:#4c4c4c
}
ul.nav {
  width:21px;
  margin:0 auto
}
ul.nav li:first-child {
  padding-top:35px
}
ul.nav li {
  padding-top:124px
}
ul.nav li a {
  -webkit-transform:rotate(270deg);
  -moz-transform:rotate(270deg);
  -o-transform:rotate(270deg);
  writing-mode:lr-tb;
  float:left;
  width:21px;
  color:#fff
}

解決方案

Rotating each a element or li element will make us encounter some problem spacing, positioning the elements exactly as we want. We should build the navigation menu so that it spreads horizontally, looks OK first then we just to need rotate the whole container of the navigation menu. Here is the updated code:

.main-nav {
  width:100vh;    
  height:45px;
  position:fixed;
  background:#4c4c4c;
  -webkit-transform-origin: left top;
  -webkit-transform:rotate(-90deg) translateX(-100%);
}
ul.nav li {    
  margin-right:20px;
  float:right;
  height:100%;
  line-height:45px;
}

The menu is supposed to have fixed height of 45px (after rotated, it will be the width). We use line-height:45px to center the a element vertically (after rotated, it will be horizontally). At first the .main-nav will lie horizontally like this:

we need to rotate it -90deg (which is counter-clockwise) around the point left - top specified by transform-origin: left top. After rotated, all the .main-nav will be out of view like this:

So we need to translate it down a distance of 100% of width, however note that we don't use translateY which seems to mean translate it vertically, because after rotated, the X axis becomes vertical (not horizontal as before), so we have to use translateX(-100%) (the positive direction is upwards, it's rightwards before rotated). Then we have:

It's just a simple use case related to transform in CSS3. For the vh unit, it's the unit relative to the viewport's height. 100vh means 100% of viewport's height. We have to use 100vh for the width because after rotated, width becomes height. It should fill the full height of the viewport. However you can set some min-width for the width by px to limit the width's minimum value. It's because when you resize the window, the viewport's height may become small and hence the width will be shrunk accordingly. Also note that instead of using float:left for the li elements, we have to use float:right so that the Home menu appears first from top to bottom, otherwise (using float:left), the Home menu will appear at the end (at bottom). There is a little advanced usage of the transform here (to newbie) it we use more than 1 transform for a transform property, all the transforms are separated by space and the order of transforms is important. Such as rotate(-90deg) translateX(-100%) means rotating -90deg first, then translating along the X axis -100%, while translateX(-100%) rotate(-90deg) is reverse to that, it's a totally different thing and of course won't work (makes an unexpected result).

Jsbin Demo.

這篇關于帶有旋轉文本的垂直導航的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to check for duplicate CSS rules?(如何檢查重復的 CSS 規則?)
Remove duplicate CSS declarations across multiple files(刪除多個文件中的重復 CSS 聲明)
Google Drive CSS/JS Returns 404 Error(Google Drive CSS/JS 返回 404 錯誤)
Adding space between buttons?(在按鈕之間添加空間?)
Sencha Touch Ext.navigation.View pop to root(Sencha Touch Ext.navigation.View pop to root)
Simple 2-column navigation with CSS and a single list?(使用 CSS 和單個列表的簡單 2 列導航?)
主站蜘蛛池模板: 免费看国产一级特黄aaaa大片 | 欧美日韩成人在线观看 | 91一区二区在线观看 | 日韩视频一区在线观看 | 欧美日韩中文字幕 | 欧美成人精品一区二区男人看 | 91精品国产91久久久久游泳池 | av男人的天堂在线 | 亚洲国产成人精品女人久久久 | 亚洲精品免费观看 | 久草在线免费资源 | 91日日 | 在线看日韩av | 毛片在线免费 | 国产99久久久久 | 国产成人精品一区二 | 午夜激情免费视频 | 国产精品视频一区二区三区 | 国产一区2区 | 国产成人免费视频 | 视频一区二区在线观看 | 国产激情在线观看视频 | 黄色大片在线免费观看 | 日韩欧美国产精品一区二区 | 久久久国产一区二区三区 | 黄色网络在线观看 | 一区二区三区四区国产 | 古装人性做爰av网站 | 国产超碰人人爽人人做人人爱 | 二区在线观看 | 嫩草网| 国产一区二区三区四区在线观看 | 欧美精品久久久 | 精品色| 在线黄色网| 亚洲欧美日韩一区二区 | 在线视频久久 | 日韩字幕一区 | 国产欧美日韩 | 国产精品一区二区三区四区 | 婷婷色国产偷v国产偷v小说 |