position: type;
top: value;
right: value;
bottom: value;
left: value;
where type
indicates the kind of positioning applied to the element and top
, right
, bottom
, and left
properties indicate the coordinates of the elementpc_info_txt.html
file from the html03 > tutorial folder. Enter your name and the date in the comment section of the file and save the document as pc_info.html
.<link href=”pc_reset.css” rel=”stylesheet” />
<link href=”pc_styles3.css” rel=”stylesheet” />
<link href=”pc_info.css” rel=”stylesheet” />
pc_info_txt.css
file from the html03 > tutorial folder. Enter your name and the date in the comment section of the file and save the document as pc_info.css
.main {
position: relative;
height: 1400px;
width: 100%;
}
It will be easier to see the effect of placing the different div elements if they are not displayed until you are ready to position them. Add a rule to hide the div elements, then as you position each element, you can add a style rule to redisplay it.
div.infobox {display:none;}
pc_info.html
file in your browser. Verify that the browser shows an empty box, about 1400 pixels high, where the infographic will be placed.div.infobox {
position: absolute;
}
div#info1 {
display: block;
top: 20px;
left: 5%;
}
Note that we set the display property to block so that the first information box is no longer hidden on the page.
pc_info.html
file in your browser. pc_info.css
file in your editor and go to the Second Infographic section.div#info2 {
display: block;
top: 185px;
left: 42%;
}
div#info3 {
display: block;
top: 135px;
left: 75%;
}
pc_info.html
in your browser. pc_info.css
file in your editor, go to the Fourth Infographic section and place the fourth box 510 pixels from the top edge and 8% from the left edge.div#info4 {
display: block;
top: 510px;
left: 8%;
}
div#info5 {
display: block;
top: 800px;
left: 3%;
}
div#info6 {
display: block;
top: 600px;
left: 48%;
}
pc_info.html
in your browser.pc_info.css
file in your editor, go to the Seventh Infographic section and insert the following style rules:div#info7 {
display: block;
top: 1000px;
left: 68%;
}
div#info8 {
display: block;
top: 1100px;
left: 12%;
}
div.infobox {display: none;}
because you no longer need to hide any information boxes.pc_info.html
in your browser.Discuss the problems one faces while using grids.
Positioning gives you a great deal of control over how your web pages look. Do some websites overuse positioning? Would the you like a website that is filled with eye-popping boxes of text or something that flows in a more linear style? Debate the pros and cons of excess positioning. Show an example of a website that has excess of positioning styles.
Overflow
–overflow: type;
where type
is visible
(the default), hidden
, scroll
, or auto
visible
–hidden
–scroll
–auto
–pc_info.css
file in your editor and go to the Main Styles section.overflow: auto;
.pc_info.html
file in your browser.Come up with instances when you might want to crop an image on a web page rather than display the whole picture. Can they think of why they might want to crop it on the web page rather than using a photo editor? Have a discussion with students on how to handle overflow in horizontal and vertical directions.
clip: rect(top, right, bottom,left);
where top
, right
, bottom
, and left
define the coordinates of the clipping rectanglez-index: value;
where value
is a positive or negative integer, or the keyword auto
z-index
property works only for elements that are placed with absolute positioningShare ways you might layer items on a page using the z-index.