SlideShare a Scribd company logo
1 of 16
Download to read offline
Web Programming and
Design
CSS (Cascading Style Sheet)
By: Gheyath M. Othman
CSS Layout (The Position Property)
2
The position property specifies the type of positioning method used for an element .
There are four different position values:
• static
• relative
• fixed
• absolute
Elements are then positioned using the top, bottom, left, and right properties.
However, these properties will not work unless the position property is set first.
They also work differently depending on the position value.
CSS Layout (The Position Property)
3
position: static;
• HTML elements are positioned static by default. It doesn’t affected by the
top, bottom, left, and right properties.
• An element with position: static; is not positioned in any special way; it is
always positioned according to the normal flow of the page:
This <div> element has position: static;
Property (position:static;)
4
Example:
<!DOCTYPE html><html><head>
<style>
div.static {
position: static;
border: 3px solid #8AC007;
}
</style>
</head>
<body>
<h2>position: static;</h2>
<p>An element with position: static; is not positioned in any
special way; it is
always positioned according to the normal flow of the page:</p>
<div class="static">
This div element has position: static;
</div>
</body>
</html>
e1_static
CSS Layout (The Position Property)
5
position: relative;
• An element with position: relative; is positioned relative to its normal
position.
• Setting the top, right, bottom, and left properties of a relatively-positioned
element will cause it to be adjusted away from its normal position. Other
content will not be adjusted to fit into any gap left by the element.
Property (position:relative;)
6
Example:
<!DOCTYPE html><html><head>
<style>
div.relative {
position: relative;
left: 180px;
border: 3px solid #8AC007;
max-width:300px;
top:0px;
}
</style>
</head>
<body>
<h2>position: relative;</h2>
<p>An element with position: relative; is positioned relative to
its normal position:</p>
<div class="relative">
This div element has position: relative;
</div>
<span>this is another text in span element</span>
</body></html>
e2_relative
CSS Layout (The Position Property)
7
position: fixed;
• An element with position: fixed; is positioned relative to the viewport,
which means it always stays in the same place even if the page is scrolled.
The top, right, bottom, and left properties are used to position the
element.
• A fixed element does not leave a gap in the page where it would normally
have been located. like
Property (position:fixed;)
8
Example:
<!DOCTYPE html><html><head>
<style>
div.fixed {
position: fixed;
bottom: 20px;
height:150px;
width: 300px;
border: 3px solid #8AC007;
background-color:#8AC007;
color:#FFF;
}
</style>
</head>
<body>
<h2>position: fixed;</h2>
<div class="fixed">
This div element has position: fixed;</div>
<p>An element with position: fixed; is positioned relative to the viewport,
which means it always stays in the same place even if the page is
scrolled:</p>
</body></html>
e2_fixed
CSS Layout (The Position Property)
9
position: absolute;
• An element with position: absolute; is positioned relative to the nearest
positioned ancestor (instead of positioned relative to the viewport, like fixed).
• However; if an absolute positioned element has no positioned ancestors, it uses
the document body, and moves along with page scrolling.
Property (position:absolute;)
10
Example:
<!DOCTYPE html><html><head>
<style>
div.relative { position: relative;
width: 400px;
height: 200px;
border: 3px solid #8AC007; }
div.absolute { position: absolute;
top: 80px;
right:0px;
width: 200px;
height: 100px;
border: 3px solid #8AC007; }
</style>
</head>
<body>
<h2>position: absolute;</h2>
<p>An element with position: absolute; is positioned relative to the nearest
positioned ancestor (instead of positioned relative to the viewport, like fixed):</p>
<div class="relative">This div element has position: relative;
<div class="absolute">This div element has position: absolute;</div> </div>
</body></html>
e2_absolute
CSS Layout (The Position Property)
11
Overlapping Elemenets
• When elements are positioned, they can overlap other elements.
• The z-index property specifies the stack order of an element (which element
should be placed in front of, or behind, the others).
• An element can have a positive or negative stack order
• An element with greater stack order is always in front of an element with a
lower stack order.
Note: If two positioned elements overlap without a z-index specified, the element
positioned last in the HTML code will be shown on top.
e2_overlap
Overlapping elements(z-index)
12
Example:
<!DOCTYPE html><html><head>
<style>
.img1 { position: absolute;
left: 0px;
top: 0px;
z-index: 1; }
.img2 { position: absolute;
left: 0px;
top: 150px;
z-index: -1; }
</style>
</head>
<body>
<h1>This is a heading</h1>
<img src="../smiley.gif" width="100" height="140" class="img1">
<p>Because the image has a z-index of -1, it will be placed behind the text.</p><span>
<br><h1>This is a heading</h1>
<img src="../smiley.gif" width="100" height="140" class="img2">
<p>Because the image has a z-index of -1, it will be placed behind the text.</p><span>
</body></html>
e2_overlap e1_overlap
CSS Layout (Change the cursor)
13
<p>Mouse over the words to change the cursor.</p>
<span style="cursor:auto">auto</span><br>
<span style="cursor:crosshair">crosshair</span><br>
<span style="cursor:default">default</span><br>
<span style="cursor:e-resize">e-resize</span><br>
<span style="cursor:help">help</span><br>
<span style="cursor:move">move</span><br>
<span style="cursor:n-resize">n-resize</span><br>
<span style="cursor:ne-resize">ne-resize</span><br>
<span style="cursor:nw-resize">nw-resize</span><br>
<span style="cursor:pointer">pointer</span><br>
<span style="cursor:progress">progress</span><br>
<span style="cursor:s-resize">s-resize</span><br>
<span style="cursor:se-resize">se-resize</span><br>
<span style="cursor:sw-resize">sw-resize</span><br>
<span style="cursor:text"> text</span><br>
<span style="cursor:w-resize">w-resize</span><br>
<span style="cursor:wait">wait</span><br>
Example e7_cursor
CSS Opacity
14
The CSS opacity property is a part of the CSS3 recommendation,
is used for transparency.
opacity: value;
The opacity property can take a value from (0.0 – 1.0) The lower value, the
more transparent .like
filter: alpha(opacity=value); /* For IE8 and earlier */
CSS Opacity (opacity: value;)
15
Example:
<!DOCTYPE html><html><head>
<style>
img {
opacity: 0.4;
}
</style>
</head>
<body>
<h1>Image Transparency</h1>
<img src="klematis.jpg" width="150"
height="113" >
</body></html>
e1_opacity
<!DOCTYPE html>
<html>
<head>
<style>
img {
opacity: 0.4;
}
img:hover {
opacity: 1.0;
}
</style>
</head>
<body>
<h1>Image Transparency</h1>
<img src="klematis.jpg" width="150" height="113"
alt="klematis">
<img src="klematis2.jpg" width="150" height="113"
alt="klematis">
<p><b>Note:</b> In IE, a !DOCTYPE must be added
for the :hover selector to work on other elements
than the a element.</p>
</body></html>
On mouse over
e2_opacity
CSS Opacity (opacity:value;)
16
Example:
<!DOCTYPE html><html><head>
<style>
div.Background {
background: url(klematis.jpg) repeat;
border: 2px solid black; }
div.Transbox {
margin: 30px;
background-color: #ffffff;
border: 1px solid black;
opacity:0.6; }
div.transbox p {
margin: 5%;
font-weight: bold;
text-align:center; }
</style>
</head>
<body><div class="background">
<div class="transbox">
<p>This is some text that is placed in the transparent box.</p>
</div></div>
</body></html>
e3_opacity

More Related Content

What's hot (20)

uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
 
Css
CssCss
Css
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSSCascading Style Sheets - CSS
Cascading Style Sheets - CSS
 
HTML 5 Simple Tutorial Part 1
HTML 5 Simple Tutorial Part 1HTML 5 Simple Tutorial Part 1
HTML 5 Simple Tutorial Part 1
 
Css notes
Css notesCss notes
Css notes
 
Intro to CSS
Intro to CSSIntro to CSS
Intro to CSS
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style Sheets
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
 
Css introduction
Css  introductionCss  introduction
Css introduction
 
CSS
CSSCSS
CSS
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
uptu web technology unit 2 html
uptu web technology unit 2 htmluptu web technology unit 2 html
uptu web technology unit 2 html
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 

Similar to Web Design Course: CSS lecture 5

Similar to Web Design Course: CSS lecture 5 (20)

CSS Positioning Elements.pdf
CSS Positioning Elements.pdfCSS Positioning Elements.pdf
CSS Positioning Elements.pdf
 
Exp13 write up
Exp13 write upExp13 write up
Exp13 write up
 
CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3
 
CSS_Dibbo
CSS_DibboCSS_Dibbo
CSS_Dibbo
 
CSS Position and it’s values
CSS Position and it’s valuesCSS Position and it’s values
CSS Position and it’s values
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Css advanced – session 4
Css advanced – session 4Css advanced – session 4
Css advanced – session 4
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)
 
CSS
CSSCSS
CSS
 
Css position
Css positionCss position
Css position
 
Web Programming Basic topic.pptx
Web Programming Basic topic.pptxWeb Programming Basic topic.pptx
Web Programming Basic topic.pptx
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
Css, xhtml, javascript
Css, xhtml, javascriptCss, xhtml, javascript
Css, xhtml, javascript
 
CSS tutorial chapter 3
CSS tutorial chapter 3CSS tutorial chapter 3
CSS tutorial chapter 3
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptx
 
Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)
 
Web Development 4
Web Development 4Web Development 4
Web Development 4
 
Css 101
Css 101Css 101
Css 101
 
Web Layout
Web LayoutWeb Layout
Web Layout
 
Css tips & tricks
Css tips & tricksCss tips & tricks
Css tips & tricks
 

Recently uploaded

Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizharallensay1
 
Puri CALL GIRL ❤️8084732287❤️ CALL GIRLS IN ESCORT SERVICE WE ARW PROVIDING
Puri CALL GIRL ❤️8084732287❤️ CALL GIRLS IN ESCORT SERVICE WE ARW PROVIDINGPuri CALL GIRL ❤️8084732287❤️ CALL GIRLS IN ESCORT SERVICE WE ARW PROVIDING
Puri CALL GIRL ❤️8084732287❤️ CALL GIRLS IN ESCORT SERVICE WE ARW PROVIDINGpriyakumari801827
 
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTSDurg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTSkajalroy875762
 
Bankura Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Available
Bankura Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service AvailableBankura Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Available
Bankura Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Availablepr788182
 
SRI GANGANAGAR 💋 Call Girl 9827461493 Call Girls in Escort service book now
SRI GANGANAGAR 💋 Call Girl 9827461493 Call Girls in  Escort service book nowSRI GANGANAGAR 💋 Call Girl 9827461493 Call Girls in  Escort service book now
SRI GANGANAGAR 💋 Call Girl 9827461493 Call Girls in Escort service book nowkapoorjyoti4444
 
Cuttack Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Cuttack Call Girl Just Call 8084732287 Top Class Call Girl Service AvailableCuttack Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Cuttack Call Girl Just Call 8084732287 Top Class Call Girl Service Availablepr788182
 
Nanded Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Nanded Call Girl Just Call 8084732287 Top Class Call Girl Service AvailableNanded Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Nanded Call Girl Just Call 8084732287 Top Class Call Girl Service Availablepr788182
 
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxQSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxDitasDelaCruz
 
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All TimeCall 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All Timegargpaaro
 
Arti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdfArti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdfwill854175
 
JHARSUGUDA CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN JHARSUGUDA ESCORTS
JHARSUGUDA CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN JHARSUGUDA ESCORTSJHARSUGUDA CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN JHARSUGUDA ESCORTS
JHARSUGUDA CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN JHARSUGUDA ESCORTSkajalroy875762
 
KOLKATA 💋 Call Girl 9827461493 Call Girls in Escort service book now
KOLKATA 💋 Call Girl 9827461493 Call Girls in  Escort service book nowKOLKATA 💋 Call Girl 9827461493 Call Girls in  Escort service book now
KOLKATA 💋 Call Girl 9827461493 Call Girls in Escort service book nowkapoorjyoti4444
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxCynthia Clay
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon investment
 
PITHAMPUR 💋 Call Girl 9827461493 Call Girls in Escort service book now
PITHAMPUR 💋 Call Girl 9827461493 Call Girls in  Escort service book nowPITHAMPUR 💋 Call Girl 9827461493 Call Girls in  Escort service book now
PITHAMPUR 💋 Call Girl 9827461493 Call Girls in Escort service book nowkapoorjyoti4444
 
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...ssuserf63bd7
 
Bangalore Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Avai...
Bangalore Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Avai...Bangalore Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Avai...
Bangalore Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Avai...pr788182
 
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service AvailableNashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Availablepr788182
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptxnandhinijagan9867
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Puja Sharma
 

Recently uploaded (20)

Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
 
Puri CALL GIRL ❤️8084732287❤️ CALL GIRLS IN ESCORT SERVICE WE ARW PROVIDING
Puri CALL GIRL ❤️8084732287❤️ CALL GIRLS IN ESCORT SERVICE WE ARW PROVIDINGPuri CALL GIRL ❤️8084732287❤️ CALL GIRLS IN ESCORT SERVICE WE ARW PROVIDING
Puri CALL GIRL ❤️8084732287❤️ CALL GIRLS IN ESCORT SERVICE WE ARW PROVIDING
 
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTSDurg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
 
Bankura Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Available
Bankura Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service AvailableBankura Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Available
Bankura Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Available
 
SRI GANGANAGAR 💋 Call Girl 9827461493 Call Girls in Escort service book now
SRI GANGANAGAR 💋 Call Girl 9827461493 Call Girls in  Escort service book nowSRI GANGANAGAR 💋 Call Girl 9827461493 Call Girls in  Escort service book now
SRI GANGANAGAR 💋 Call Girl 9827461493 Call Girls in Escort service book now
 
Cuttack Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Cuttack Call Girl Just Call 8084732287 Top Class Call Girl Service AvailableCuttack Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Cuttack Call Girl Just Call 8084732287 Top Class Call Girl Service Available
 
Nanded Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Nanded Call Girl Just Call 8084732287 Top Class Call Girl Service AvailableNanded Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Nanded Call Girl Just Call 8084732287 Top Class Call Girl Service Available
 
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxQSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
 
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All TimeCall 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
 
Arti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdfArti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdf
 
JHARSUGUDA CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN JHARSUGUDA ESCORTS
JHARSUGUDA CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN JHARSUGUDA ESCORTSJHARSUGUDA CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN JHARSUGUDA ESCORTS
JHARSUGUDA CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN JHARSUGUDA ESCORTS
 
KOLKATA 💋 Call Girl 9827461493 Call Girls in Escort service book now
KOLKATA 💋 Call Girl 9827461493 Call Girls in  Escort service book nowKOLKATA 💋 Call Girl 9827461493 Call Girls in  Escort service book now
KOLKATA 💋 Call Girl 9827461493 Call Girls in Escort service book now
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business Growth
 
PITHAMPUR 💋 Call Girl 9827461493 Call Girls in Escort service book now
PITHAMPUR 💋 Call Girl 9827461493 Call Girls in  Escort service book nowPITHAMPUR 💋 Call Girl 9827461493 Call Girls in  Escort service book now
PITHAMPUR 💋 Call Girl 9827461493 Call Girls in Escort service book now
 
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
 
Bangalore Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Avai...
Bangalore Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Avai...Bangalore Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Avai...
Bangalore Call Girl Just Call♥️ 8084732287 ♥️Top Class Call Girl Service Avai...
 
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service AvailableNashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptx
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
 

Web Design Course: CSS lecture 5

  • 1. Web Programming and Design CSS (Cascading Style Sheet) By: Gheyath M. Othman
  • 2. CSS Layout (The Position Property) 2 The position property specifies the type of positioning method used for an element . There are four different position values: • static • relative • fixed • absolute Elements are then positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. They also work differently depending on the position value.
  • 3. CSS Layout (The Position Property) 3 position: static; • HTML elements are positioned static by default. It doesn’t affected by the top, bottom, left, and right properties. • An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page: This <div> element has position: static;
  • 4. Property (position:static;) 4 Example: <!DOCTYPE html><html><head> <style> div.static { position: static; border: 3px solid #8AC007; } </style> </head> <body> <h2>position: static;</h2> <p>An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page:</p> <div class="static"> This div element has position: static; </div> </body> </html> e1_static
  • 5. CSS Layout (The Position Property) 5 position: relative; • An element with position: relative; is positioned relative to its normal position. • Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content will not be adjusted to fit into any gap left by the element.
  • 6. Property (position:relative;) 6 Example: <!DOCTYPE html><html><head> <style> div.relative { position: relative; left: 180px; border: 3px solid #8AC007; max-width:300px; top:0px; } </style> </head> <body> <h2>position: relative;</h2> <p>An element with position: relative; is positioned relative to its normal position:</p> <div class="relative"> This div element has position: relative; </div> <span>this is another text in span element</span> </body></html> e2_relative
  • 7. CSS Layout (The Position Property) 7 position: fixed; • An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element. • A fixed element does not leave a gap in the page where it would normally have been located. like
  • 8. Property (position:fixed;) 8 Example: <!DOCTYPE html><html><head> <style> div.fixed { position: fixed; bottom: 20px; height:150px; width: 300px; border: 3px solid #8AC007; background-color:#8AC007; color:#FFF; } </style> </head> <body> <h2>position: fixed;</h2> <div class="fixed"> This div element has position: fixed;</div> <p>An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled:</p> </body></html> e2_fixed
  • 9. CSS Layout (The Position Property) 9 position: absolute; • An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed). • However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
  • 10. Property (position:absolute;) 10 Example: <!DOCTYPE html><html><head> <style> div.relative { position: relative; width: 400px; height: 200px; border: 3px solid #8AC007; } div.absolute { position: absolute; top: 80px; right:0px; width: 200px; height: 100px; border: 3px solid #8AC007; } </style> </head> <body> <h2>position: absolute;</h2> <p>An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed):</p> <div class="relative">This div element has position: relative; <div class="absolute">This div element has position: absolute;</div> </div> </body></html> e2_absolute
  • 11. CSS Layout (The Position Property) 11 Overlapping Elemenets • When elements are positioned, they can overlap other elements. • The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others). • An element can have a positive or negative stack order • An element with greater stack order is always in front of an element with a lower stack order. Note: If two positioned elements overlap without a z-index specified, the element positioned last in the HTML code will be shown on top. e2_overlap
  • 12. Overlapping elements(z-index) 12 Example: <!DOCTYPE html><html><head> <style> .img1 { position: absolute; left: 0px; top: 0px; z-index: 1; } .img2 { position: absolute; left: 0px; top: 150px; z-index: -1; } </style> </head> <body> <h1>This is a heading</h1> <img src="../smiley.gif" width="100" height="140" class="img1"> <p>Because the image has a z-index of -1, it will be placed behind the text.</p><span> <br><h1>This is a heading</h1> <img src="../smiley.gif" width="100" height="140" class="img2"> <p>Because the image has a z-index of -1, it will be placed behind the text.</p><span> </body></html> e2_overlap e1_overlap
  • 13. CSS Layout (Change the cursor) 13 <p>Mouse over the words to change the cursor.</p> <span style="cursor:auto">auto</span><br> <span style="cursor:crosshair">crosshair</span><br> <span style="cursor:default">default</span><br> <span style="cursor:e-resize">e-resize</span><br> <span style="cursor:help">help</span><br> <span style="cursor:move">move</span><br> <span style="cursor:n-resize">n-resize</span><br> <span style="cursor:ne-resize">ne-resize</span><br> <span style="cursor:nw-resize">nw-resize</span><br> <span style="cursor:pointer">pointer</span><br> <span style="cursor:progress">progress</span><br> <span style="cursor:s-resize">s-resize</span><br> <span style="cursor:se-resize">se-resize</span><br> <span style="cursor:sw-resize">sw-resize</span><br> <span style="cursor:text"> text</span><br> <span style="cursor:w-resize">w-resize</span><br> <span style="cursor:wait">wait</span><br> Example e7_cursor
  • 14. CSS Opacity 14 The CSS opacity property is a part of the CSS3 recommendation, is used for transparency. opacity: value; The opacity property can take a value from (0.0 – 1.0) The lower value, the more transparent .like filter: alpha(opacity=value); /* For IE8 and earlier */
  • 15. CSS Opacity (opacity: value;) 15 Example: <!DOCTYPE html><html><head> <style> img { opacity: 0.4; } </style> </head> <body> <h1>Image Transparency</h1> <img src="klematis.jpg" width="150" height="113" > </body></html> e1_opacity <!DOCTYPE html> <html> <head> <style> img { opacity: 0.4; } img:hover { opacity: 1.0; } </style> </head> <body> <h1>Image Transparency</h1> <img src="klematis.jpg" width="150" height="113" alt="klematis"> <img src="klematis2.jpg" width="150" height="113" alt="klematis"> <p><b>Note:</b> In IE, a !DOCTYPE must be added for the :hover selector to work on other elements than the a element.</p> </body></html> On mouse over e2_opacity
  • 16. CSS Opacity (opacity:value;) 16 Example: <!DOCTYPE html><html><head> <style> div.Background { background: url(klematis.jpg) repeat; border: 2px solid black; } div.Transbox { margin: 30px; background-color: #ffffff; border: 1px solid black; opacity:0.6; } div.transbox p { margin: 5%; font-weight: bold; text-align:center; } </style> </head> <body><div class="background"> <div class="transbox"> <p>This is some text that is placed in the transparent box.</p> </div></div> </body></html> e3_opacity