0
How to add image in css with the help of class or id?
image should be in left or right but not a background as all uses background-image not this just like in html we give <img> tag like that but the use of this in a class or id ?
4 Answers
+ 1
css has 3 main things
"selectors" (not sure what they are called lol)
are accessed like
header {}
nav ol li {}
then classes, class="css-label"
.css-label {}
.generalClassName {}
or an id
<div id="main">...
#main {}
#picture {}
ect.
for the whole img thing...
do
<img src... alt.... class="myPic"/>
then in styles
.myPic {
height: 50%;
width:50%;
float:left;
others...
}
hope this helps.
+ 1
With:
<img src="picture.url" id="myPicID" class="myClass" alt="description">
... you can target it by "selecting" it ( selector is the right word ;) ) by different ways:
img { /* rules targets all <img> elements */ }
#myPic { /* target all id 'myPic' ( but they're supposed to be unique ^^ ) */ }
.myClass { /* target all elements with class 'myClass' */ }
And you can combine them:
img.myClass { /* target only <img> with class 'myClass' */ }
... as well as associate parent and children in the selector:
div.myStyle img.myClass { /* will target all <img> with class 'myClass', which are childs ( contained in ) of all <div> with class 'myStyle' */ }
Also, a lot of css selector operators exists, now with Css3, to make accurates rules ;)
However, handling complex css selectors, require to good understanding too how priorities, inherits, and so on works in the "Cascading Style Sheet" context, as order of rules are not the only criterion to decide overwriting or not a property ^^
0
thank you so much!
0
thnx ol fr help n keep sharing knwoledge fr free thnk u!