Reputation: 121
I want to style and centre some pics that do not have any classes, only titles and some inline CSS styling already.
Is this possible to style this pic (make it 100% width) via a stylesheet using CSS only. Can CSS attributes whilst keeping the inline CSS in the HTML?
<img alt="My Third pic" src="http://www.example.com/thirdproduct" style="border-style:solid; border-width:10px; height:240px; width:220px" title="Third Pic">
How do I target an image by using the title, this is what I have so far
img [title~="Third Pic"] {
width:100%
}
Upvotes: 0
Views: 272
Reputation: 14575
If I understand correctly, you just need to get rid of the tilde (~) and the space between img and [title, as well as making the rule !important so it'll override the inline style
img[title="Third Pic"] {
width: 100% !important;
}
Upvotes: 1
Reputation: 322
you can add this CSS to style the images based on the img tag
.parentDiv img{
width:100%;
}
or if you need the third img to have the style
.parentDiv img:nth-child(3){
width:100%;
}
Upvotes: 0