CSS Advanced #1

 CSS

  • CSS Rounded Corners

With the CSS border-radius property, you can give any element "rounded corners".

Example : 

#rcorners1 {
  border-radius: 25px;
  background: #73AD21;
  padding: 20px;
  width: 200px;
  height: 150px;
}

Four values - border-radius: 15px 50px 30px 5px; 

(first value applies to top-left corner, second value applies to top-right corner, third value applies to bottom-right corner, and fourth value applies to bottom-left corner)


  • CSS Overflow

The overflow property specifies whether to clip the content or to add scrollbars when the content of an element is too big to fit in the specified area.

The overflow property has the following values:

  • visible - Default. The overflow is not clipped. The content renders outside the element's box
  • hidden - The overflow is clipped, and the rest of the content will be invisible
  • scroll - The overflow is clipped, and a scrollbar is added to see the rest of the content
  • auto - Similar to scroll, but it adds scrollbars only when necessary

Example : 

div {
  width: 200px;
  height: 50px;
  background-color: #eee;
  overflow: visible;
  overflow: hidden;
  overflow: scroll;
  overflow: auto;
}


  • CSS Navigation Bar
Having easy-to-use navigation is important for any web site.

Example :

Simple Na-bar with links:
<ul>
  <li><a href="default.asp">Home</a></li>
  <li><a href="news.asp">News</a></li>
  <li><a href="contact.asp">Contact</a></li>
  <li><a href="about.asp">About</a></li>
</ul>

Removing the bullets from the Nav-Bar:
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

Vertical Navigation-Bar:

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  width: 60px;
}

li a {
  display: block;
}

Horizontal Navigation-Bar:

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
}

li {
  float: left;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

Fixed Navigation-Bar:

Fixed top Nav-Bar:

ul {
  position: fixed;
  top: 0;
  width: 100%;
}

Fixed Bottom Nav-Bar:

ul {
  position: fixed;
  bottom: 0;
  width: 100%;
}

CSS icons
The simplest way to add an icon to your HTML page, is with an icon library, such as Font Awesome.
Add the name of the specified icon class to any inline HTML element (like <i> or <span>).

Use font-awsome Icons:

<script src="https://kit.fontawesome.com/yourcode.js"></script>

Example:

<i class="fas fa-cloud"></i>
<i class="fas fa-heart"></i>
<i class="fas fa-car"></i>
<i class="fas fa-file"></i>
<i class="fas fa-bars"></i>


Use google icons:

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

Example:

<i class="material-icons">cloud</i>
<i class="material-icons">favourite</i>
<i class="material-icons">attachment</i>
<i class="material-icons">computer</i>
<i class="material-icons">traffic</i>


CSS Links:

The four links states are:

  • a:link - a normal, un-visited link
  • a:visited - a link the user has visited
  • a:hover - a link when the user mouses over it
  • a:active - a link the moment it is clicked

CSS Shadows:

With CSS you can add shadow to text and to elements.

In these chapters you will learn about the following properties:

  • text-shadow
  • box-shadow
Example :

h1 {
  text-shadow: 2px 2px;
}

h1 {
  text-shadow: 2px 2px 5px red;
}// adding a blur effect to the shadows

Multiple Shadows :

Example :

h1 {
  text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
}

Box Shadows:

Example :

div {
  box-shadow: 10px 10px;
  box-shadow: 10px 10px grey;
  box-shadow: 10px 10px 5px grey;
}


CSS 3D Transform:

CSS also supports 3D transformations.

With the CSS transform property you can use the following 3D transformation methods:

  • rotateX()
  • rotateY()
  • rotateZ()
Example :

#myDiv {
  transform: rotateX(150deg);
  transform: rotateY(130deg);
  transform: rotateZ(90deg);
}

Responsive Sidebar:

<div class="sidebar">
  <a class="active" href="#home">Home</a>
  <a href="#news">News</a>
  <a href="#contact">Contact</a>
  <a href="#about">About</a>
</div>

Add CSS to it:

.sidebar {
  margin: 0;
  padding: 0;
  width: 200px;
  background-color: #f1f1f1;
  position: fixed;
  height: 100%;
  overflow: auto;
}

.sidebar a {
  display: block;
  color: black;
  padding: 16px;
  text-decoration: none;
}

.sidebar a.active {
  background-color: #4CAF50;
  color: white;
}

Apply Media Queries:

@media screen and (max-width: 700px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  
}
  .sidebar a {float: left;}
  div.content {margin-left: 0;}
}










Comments

Popular posts from this blog

Java Basics #4

BootStrap Advanced #3

CSS Advanced #2