[Learning]#10 CSS3 Flexbox: nav style setting

Vida Lin
2 min readSep 28, 2021

What is nav?

  • nav = navagator
  • “The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.” by Mozilla

Resource: https://pixabay.com/

Final Design

Horizontal alignment with Flex

Before

nav{}

nav>.logo{
background-color:#ffcccc;
}
nav>.menu{
background-color:#ccccff;
}
nav>.user{
background-color:#ccffcc;
}

After

nav{
display: flex;
}

nav>.logo{
flex:none;width:100px;
background-color:#ffcccc;
}
nav>.menu{
flex:none;
background-color:#ccccff;
}
nav>.user{
flex:none;width:100px;
background-color:#ccffcc;
}

If you want the menu to extend automatically, replace the “none” of menu with “auto.” The length of menu will adapt to the page size while we change its pixel.

Music of Today: Thunder by Imagine Dragons

Clap/Share/Follow

If you guys find this article helpful, please kindly do the writer a favor — giving 5 clicks at the GREEN area and 10~50 claps at the bottom of this page.

Most important of all, feel free to comment and share your ideas below to learn together!

Vida Lin
Vida Lin

Written by Vida Lin

PM, Relationship, Travel, or anything quirky but interesting.|Subscribe & buy Vida a drink @LikerLand, the bottom of each article. 在文章底下LikerLand訂閱、請Vida喝一杯飲料 ❤

Responses (1)

Write a response

哇竟然開始學css了
不過其實 nav>.logo 這樣用箭頭的寫法指定階層,會讓css 選擇器要用比較多效能,而且會讓你的結構卡死,除非你能確定你的logo永遠會在nav下面,不會變動
不然建議保持一點彈性會比較好

10