To begin working with images by displaying them and controlling how they are displayed.
Web Programming book reading for THIS class
img
ElementWeb Programming book reading for NEXT class
section
, article
, and aside
Elementsnav
and a
Elementsheader
and footer
ElementsQuestions from our last class or the readings?
plain image |
with border |
distorted |
with title (hover over to see tooltip) |
|
<img src="...">
<br>
tag, an <img>
tag does not
have to be closed in HTML5 border
attribute — in pixels height
and width
attributes — in pixels height
or a width
attribute
sizes the image proportionally height
and a width
attribute
can distort the image’s proportions (which may be desired) title
attribute title
, all of the above can (and perhaps should) be done
with CSSimg { /* the rules here apply to ALL images */ width: 50px ; /* this is the width for ALL of the images */ } img#id { /* next we ADD styling for a SPECIFIC image */ border: 2px solid #600 ; /* brownish */ /* height: not specified because it varies */ /* the title can NOT be specified with CSS, it must be an attribute */ }
:hover
pseudo-class.navbutton { /* required so that .navbutton:hover produces a round glow */ border-radius: 50% ; } .navbutton:hover { /* glow added when the user hovers over a navigation button */ z-index: 10 ; /* bring the glow on top of other buttons */ box-shadow: 0 0 12px 3px green ; /* see below */ }
e.g., box-shadow: 60px -16px teal;
e.g., box-shadow: 10px 5px 5px black;
e.g., box-shadow: 2px 2px 2px 1px rgb(0, 0, 0);
e.g., box-shadow: inset 5em 1em gold;
e.g., box-shadow: 3px 3px red, -1em 0 0.4em olive;
<a href="..."><img src="..."></a>
Positioning
"vertical-align: top"
or "vertical-align: middle"
or "vertical-align: bottom"
"float: left"
or "float: right"
or "text-align: center"
aligned left | aligned center | aligned right |
---|---|---|
This text comes before the image in the HTML file. This text comes after the image in the HTML file. | This text comes before the image in the HTML file. This text comes after the image in the HTML file. | This text comes before the image in the HTML file. This text comes after the image in the HTML file. |
The above image has attribute style="float: left" , so
the text wraps around it. Notice that the second sentence starts right after
the first sentence as if the image wasn’t even there.
|
The above image is inline, which is the default positioning. The text does not wrap around the image. The image itself is treated just like text, that is, as if the image is simply a text character. |
The above image has attribute style="float: right" , so
once again the text wraps around it. Notice again that the second sentence
starts right after the first sentence as if the image wasn’t even there.
|
Goal: To create a web page that incorporates graphics.
Preamble: There are three exercises outlined here. They range from easier to harder. You are welcome to do whichever exercises you’d like or something similar of your own design.
If you are reading this text on paper, be sure to go to the course website to be able to easily click the links for the graphics and other page componenets you need to complete these exercises.
rgb(44,25,27)
for the dark brown page background body
element rgb(242,88,34)
for the reddish orange title background<img src="/StudentResources/PRO_Manual/Graphics/PRO%20ICONS-0.jpg">
<div>
elements.
This is tricky. Use this
starter code to help you get
started. vw
and vh
units in the CSS for the left
div to get the columns to expand to the desired viewport percentages.
30vw
is 30% of the viewport width, and 100vh
is 100% of
the viewport height.
This is Class No. 9. It was last modified on
Saturday, October 21, 2023 at 4:38 PM. Copyright © 2010-2024 by Jesse M. Heines. All rights reserved, but may be freely copied or excerpted for
educational purposes with credit to the author.