- This topic is empty.
March 1, 2016 at 6:20 pm #238596deltaParticipant
I dont like working with img tags so instead im using div tags and creating style background-image attributes, so instead of :
[img src=”example.png” /]
My images look like this
[div style=”background-image:url(‘exaple.png’); width:250px; height:250px;”]
The problem is, the width and height attribute only apply to the div and the not image being used as the background for the div. how do i resize the image with css? I could resize the images in photoshop but id like to use the same file for multiple devices and have the code resize the image instead of have multiple image files for different devices with different screen sizes. How do i do this?March 1, 2016 at 6:56 pm #238597ShikkedielParticipant
background-sizeproperty’s for that. Also worth having a look at the other background values – and how to write shorthand.March 2, 2016 at 12:31 am #238605Paulie_DModerator
I dont like working with img tags so instead im using div tags and creating style background-image attributes instead.
Then you’re probably doing something wrong.
Unless these are for styling….these should be image tags..it sounds like they are content.
Creating empty divs to show content images is very poor practice….and screenreaders will choke on it.March 2, 2016 at 1:09 pm #238620ShikkedielParticipant
A disadvantage of background images is also that they are not included in the window onload event…
- The forum ‘CSS’ is closed to new topics and replies.