Cara menggunakan create div in javascript


Text Alignment

The w3-left-align and the w3-right-align classes are used to align text.

Left aligned text.

Right aligned text.

Example


 

Left aligned text.


 

Right aligned text.


Try It Yourself »


Centering Elements

The w3-center class is used to center-align elements:

Centered Content

Cara menggunakan create div in javascript

Some centered text.

Example


 

Centered Content


 
Cara menggunakan create div in javascript

 

Some centered text.


Try It Yourself »



Wide Text

The w3-wide class specifies a wider text:

This text is normal.

This text is wider.

Example

The w3-wide class specifies a wider text.

Try It Yourself »


Text Opacity

The w3-opacity class is designed to work with all colors:

Text Opacity

Text Opacity

Text Opacity

Text Opacity

Example


 

Text Opacity


Try It Yourself »


Text Shadow

The CSS3 text-shadow property can be used to add shadow or blur effects to text:

Text Shadow

Text Shadow

Text Shadow

Text Shadow

Example

Text Shadow

Try It Yourself »


Special Effects

Text Opacity + Bold

Yellow Text + Shadow + Bold

Orange Text + Shadow + Bold

Example


 


  Text Opacity + Bold



 


  Yellow Text + Shadow + Bold



 


  Orange Text + Shadow + Bold


Try It Yourself »

Text Shadow does not work in IE 9 and earlier.





W3.CSS Navigation Bar Classes

W3.CSS provides the following classes for navigation bars:

ClassDefines
w3-bar Horizontal container for HTML elements
w3-bar-block Vertical container for HTML elements
w3-bar-item Container bar elements
w3-sidebar Vertical sidebar for HTML elements
w3-mobile Makes any bar element mobile-first responsive
w3-dropdown-hover Hoverable dropdown element
w3-dropdown-click Clickable dropdown element (instead of hover)

Basic Navigation

The w3-bar class is a container for displaying HTML elements horizontally.

The w3-bar-item class defines the container elements.

It is a perfect tool for creating navigation bars:

Example


  Home
  Link 1
  Link 2
  Link 3

Try It Yourself »



Responsive Navigation

The w3-mobile class makes any bar elements responsive (horizontal on large screens and vertical on small).

Medium and large screens:

Example


  Home
  Link 1
  Link 2
  Link 3

Try It Yourself »


Colored Navigation Bars

Use a w3-color class to add a color to the navigation bar:



Example



Try It Yourself »


Bordered Navigation Bars

Use a w3-border or w3-card class to add borders around the navigation bar, or to display it as a card:



Example


Try It Yourself »


Add a w3-color class to a link to highlight it:


Example


  Home
  Link 1
  Link 2
  Link 3

Try It Yourself »


When you mouse over a button, the background color will change to grey.

If you want a different background color on hover, use any of the w3-hover-color classes:

Example


  Home
  Link 1
  Link 2
  Link 3

Try It Yourself »

If you want to change the text color instead, turn off the default hover effect with the w3-hover-none class, and add a w3-hover-text class.

Example

Try It Yourself »

Spend some time to play around with different hover effects:




Example

Try It Yourself »


Use the w3-right class on a list item to right-align a specific link:

Example


  Home
  Link 1
  Link 2
  Link 3

Try It Yourself »


Use a w3-size class to change the font-size of the links inside the navbar:


Example


Try It Yourself »

Use a w3-padding class to change the padding of each link inside the navbar:


Example


  Home
  Link 1
  Link 2
  Link 3

Try It Yourself »

Note: You can also add padding to the navigation bar, instead of each button. However, if you do this, note that the links do not get full padding on hover:

Customize the width of the links with the CSS width property

(Note: Use w3-mobile to transform the links to 100% width on small screens):


Example

Try It Yourself »


Example


 
 
 
 
 

Try It Yourself »

The "fa fa" classes in the example above display "Font Awesome" icons.

Learn more about how to display icons in the chapter W3.CSS Icons.


If you want text instead of buttons inside the navigation bar, use the w3-bar-item class to get the same padding as the buttons.

Example


  Home
  Link 1
  Link 2
  Link 3
  Text

Try It Yourself »


Example


  Home
  Link 1
  Link 2
 
  Go

Try It Yourself »


Move the mouse over the "Dropdown" link:

Example


  Home
  Link 1
 

   
   

      Link 1
      Link 2
      Link 3
   

 

Try It Yourself »


Clickable Dropdown

Use w3-dropdown-click if you prefer to click on the dropdown link instead of hover:

Example


 
 

    Link 1
    Link 2
    Link 3
 

Try It Yourself »


Horizontal Dropdown Menu

Remove the w3-bar-block class from the dropdown container if you want the dropdown links to display horizontally instead of vertically:

Example


  Home
  Link 1
 

   
   

      Link 1
      Link 2
      Link 3
   

 

Try It Yourself »


Responsive Navbar with Responsive Dropdown

Use the w3-mobile class on all links including the dropdown container to create a responsive navbar with responsive dropdown links.

Resize the browser window to see the effect:

Example


  Home
  Link 1
  Link 2
 

   
   

      Link 1
      Link 2
      Link 3
   

 

Try It Yourself »


Fixed Navigation Bar

To force the navigation bar to stay at the top or at the bottom of the page, even when the user scrolls the page, wrap a

element around the bar and add the w3-top or w3-bottom class:

Fixed Top


 

    ...
    ...
 

Try it Yourself »

Fixed Bottom


 

    ...
    ...
 

Try it Yourself »


Vertical Navigation Bar

The w3-bar-block class is a container for displaying HTML elements vertically.

Example

Try It Yourself »


Collapsing the Navigation Bar

When the navigation bar takes up too much space on a small screen, and you do not want to display it vertically by default, you can use hide and show classes on specific links in the navigation bar.

In the example below, the navigation bar is replaced with a button (☰) in the top right corner when shown on tablets and mobile devices. When the button is clicked, the links in the navigation bar will vertically stack:


Side Navigation

The w3-sidebar class creates a side navigation:

Go to the next chapter to learn more about the side navigation.