#CSS Opacity/Transparency;
The CSS Opacity property specifies the opacity/ transparency of an element. The opacity property can take a value from 0.0-1.0, The lower value, the more transparent.
Value range:
- Opacity: 0.0; makes the elements invisible.
- Opacity: 0.5; makes the element 50% see through.
- Opacity: 1.0; Is the default value, making the element fully solid.
For example:-<html>
<head>
<style type="text/css">
body
{
margin:25px;
}
.king
{
background-color: deeppink;
height:230px;
width:300px;
border: solid 4px aquamarine;
border-radius:40px;
opacity:0.5;
}
</style>
<title></title>
</head>
<body>
<div class="king"></div>
</body>
</html>
When we set Opacity 0.5 is makes the element 50% transperant.like;
When we set Opacity 1.0, is making the element fully solid. Like;
For example:-
<html>
<head>
<style type="text/css">
body
{
margin:25px;
}
.king
{
background-color:deeppink;
height:230px;
width:300px;
border:solid 6px aquamarine;
border-radius:40px;
opacity:1.0;
}
</style>
<title></title>
</head>
<body>
<div class="king"></div>
</body>
</html>
Output is:
Let's try to understand CSS Opacity with one more example like;
<html>
<head>
<style>
div
{
background-color:palevioletred;
padding:10px;
}
div.first
{
opacity: 0.2;
}
div.second
{
opacity: 0.3;
}
div.third
{
opacity: 0.4;
}
div.fourth
{
opacity: 0.6;
}
</style>
</head>
<body>
<h1>The opacity Property</h1>
<div class="first"><p>opacity 0.2</p></div>
<div class="second"><p>opacity 0.3</p></div>
<div class="third"><p>opacity 0.4</p></div>
<div><p>opacity 1 (default)</p></div>
<div class="fourth"><p>opacity 0.6</p></div>
</body>
</html>
CSS Tables;
The CSS table helps you to define layout of table. CSS provide several properties specifically for styling HTML tables in addition to general properties like; border, padding, background-color.
The CSS general properties for styling tables;
- border-collapse: it's controls whether borders merge or remain separate.
- border-spacing: It's sets the distance between the cell's borders when they are separate.
- horizontal and vertical alignment: It's control the horizontal and vertical alignment of content within cells.
- border: it's used to provide width, style and color of an HTML element.
- background-color: it's provide style to rows.
- width and height: it's used to set the size of table.
Let's try to understand CSS Tables with example:
<html>
<head>
<style type="text/css">
table
{
border-collapse: collapse;
width:350px;
height:300px
}
table,td,th
{
border: groove 1px black;
}
td
{
text-align: center;
vertical-align: bottom;
}
th
{
background-color: deeppink;
}
</style>
<title>
</title>
</head>
<body>
<table>
<tr>
<th colspan="3" >Employee Data</th>
</tr>
<tr>
<td>Emp Id</td>
<td>Name</td>
<td>salary</td>
</tr>
<tr>
<td>101</td>
<td>Taniya</td>
<td>20,000</td>
</tr>
<tr>
<td>102</td>
<td>Bobby</td>
<td>24,000</td>
</tr>
<tr>
<td>103</td>
<td>Riya</td>
<td>19,000</td>
</tr>
</table>
</body>
</html>
Output is:
<html>
<head>
<style type="text/css">
table
{
border-collapse: collapse;
width:350px;
height:300px;
}
table,td,th
{
border: groove 1px black;
}
td
{
text-align: center;
vertical-align: bottom;
}
th
{
background-color: deeppink;
}
tr:hover
{
background-color:cyam;
}
</style>
<title>
</title>
</head>
<body>
<table>
<tr>
<th colspan="3" >Employee Data</th>
</tr>
<tr>
<td>Emp Id</td>
<td>Name</td>
<td>salary</td>
</tr>
<tr>
<td>101</td>
<td>Taniya</td>
<td>20,000</td>
</tr>
<tr>
<td>102</td>
<td>Bobby</td>
<td>24,000</td>
</tr>
<tr>
<td>103</td>
<td>Riya</td>
<td>19,000</td>
</tr>
</table>
</body>
</html>
Output is:
CSS Tables style with tr:nth-child property;
<html>
<head>
<style type="text/css">
table
{
bordercollapse:collapse;
width: 350px;
border:solid 4px limegreen;
}
th,td
{
border-bottom:ridge 3px black;
text-align: center;
}
th
{
background-color:orange;
}
tr:nth-child(even)
{
background-color:rgb(244,150,220);
}
tr:nth-child(odd)
{
background-color:rgb(134,155,180);
}
</style>
</head>
<body>
<table>
<tr>
<th colspan="3" >Employee Data</th>
</tr>
<tr>
<td>Emp Id</td>
<td>Name</td>
<td>salary</td>
</tr>
<tr>
<td>101</td>
<td>Taniya</td>
<td>20,000</td>
</tr>
<tr>
<td>102</td>
<td>Bobby</td>
<td>24,000</td>
</tr>
<tr>
<td>103</td>
<td>Riya</td>
<td>19,000</td>
</tr>
<tr>
<td>104</td>
<td>Priya</td>
<td>16,000</td>
</tr>
</table>
</body>
</html>
Output is:
CSS layout - The display property:
CSS display property defines how an element is rendered on a web page and how it interacts with other elements in the layout. It control a whether an element is treated as a block, inline, grid, flex, or other box type.
The Common CSS display property:-
- block: Starts on a new line and takes up the full width.
- inline: The element does not start on a new line and only takes up as much width as it's content requires.
- inline-block: This value combines the features of both inline and block.
- none: It takes up no space.
- Flex: It's excellent for creating flexible, responsive layouts.
- grid: This value makes an element a block-level grid container.
CSS - Layout - The postion property;
There are four different positions values:
- Static: This is default value for all HTML documents.
- Relative: The element is positioned relative to its normal position in the document flow.
- Fixed: The element is stays in the same place even when page is scrolled.
- Sticky: The value is a hybrid of relative and fixed.
Comments
Post a Comment