Display inline-block using @media - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Media

Description

Display inline-block using @media

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
ul {<!--from   ww w  .j  a va  2s. c om-->
   list-style-type:none;
}

h1, h2, ul {
   margin:0;
   padding:0;
   font-weight:normal;
}

header {
   display:block;
}

header input {
   border:2px solid Chartreuse;
   font-size:13px;
   padding-left:6px;
   padding-right:26px;
   margin-right:0;
}

header button {
   font-size:13px;
   color:yellow;
   margin-left:0;
   background-color:blue;
   border:2px solid pink;
   padding:2px 16px;
}

header .logo {
   display:inline-block;
}

header .logo>a:before {
   content:url('https://www.java2s.com/style/demo/Google-Chrome.png');
}

header .logo>h1 {
   display:inline-block;
   font-size:28px;
   margin:-3px 0 0 11px;
   vertical-align:top;
}

header .search-contact {
   display:inline-block;
   vertical-align:top;
   margin-top:4px;
   float:right;
}

nav li.active {
   background:linear-gradient(to bottom, OrangeRed 2%, grey 100%);
}

nav li:not(.active):hover {
   background:linear-gradient(to bottom, BlueViolet 0%,Chartreuse 100%);
}

nav li:not(.active):hover a {
   color:yellow;
}

nav li.active a {
   color:blue;
}

nav.tabs {
   clear:both;
   background:linear-gradient(to bottom, pink 0%, OrangeRed 100%);
   margin-bottom:16px;
}

nav.tabs ul {
   display:block;
}

nav.tabs a {
   color:grey;
}

nav.tabs ul>li {
   display:inline-block;
   padding:11px 21px;
   margin-right:-5px;
}

nav.tabs ul>li a {
   display:block;
   font-weight:bold;
   text-decoration:none;
}

nav.tabs ul>li:first-child {
   float:right;
   margin:0;
}

@media all and (max-width: 670px)  {
   nav.tabs ul>li {
      padding:11px 8px;
   }

}

@media all and (max-width: 480px)  {
   nav.tabs ul {
      padding-bottom:31px;
      position:relative;
   }
   
   nav.tabs ul>li {
      padding:6px 0 6px 11px;
      display:block;
      float:none !important;
      margin-right:0;
   }
   
   nav.tabs ul>li:first-child {
      bottom:0;
      float:none;
      left:0;
      position:absolute;
      right:0;
   }

}
</style> 
 </head> 
 <body> 
  <header> 
   <div class="logo"> 
    <a href="#"></a> 
    <h1>Lorem ipsum dolo</h1> 
   </div> 
   <div class="search-contact"> 
    <input type="text" placeholder="Search contact here"> 
    <button>Lorem </button> 
   </div> 
  </header> 
  <nav class="tabs"> 
   <ul> 
    <li> <a href="#">Lorem ips</a> </li> 
    <li> <a href="#">Lor</a> </li> 
    <li class="active"> <a href="#">Lorem ips</a> </li> 
    <li> <a href="#">Lorem ipsum d</a> </li> 
    <li> <a href="#">Lorem ipsum</a> </li> 
   </ul> 
  </nav>  
 </body>
</html>

Related Tutorials