Reputation: 119
So what I'm trying to do is select an img tag and change the size of it, I tried to use a class selector and id but they don't seem to work, I got this to work locally but as soon as I upload it to the server the css doesn't take effect
html
<div id="logo3">
<img src="img/fehr.png" alt="logo">
</div>
css I tried but doesn't work:
img[src="img/fehr.png"] {
height: 90px;
width: auto;
}
img[alt~="logo"] {
height: 90px;
width: auto;
}
#logo3 {
height: 90px;
width: auto;
}
css that works:
img { height: 90px; width: auto; }
but I want to use a selector incase I add more images later.
Upvotes: 3
Views: 1618
Reputation: 18840
This works for me ...
html
<div id="logo3"><img src="img/fehr.png" alt="logo"></div>
css
img[src="img/fehr.png"] {
height: 100px;
width: auto;
background-color: red;
}
//the other two also works
Try adding '!important' on the end, and check if nothing overwrite your css.
img[src="img/fehr.png"] {
height: 100px!important;
width: auto!important;
background-color: red!important;
}
Upvotes: 0
Reputation: 1526
You can Try
#logo3 img{
height: 90px; width: auto;
}
Or with Jquery
$('#logo3 img').css('height','90');
Upvotes: 1