Darkmatter5 Posted November 6, 2008 Share Posted November 6, 2008 The topic says it all. Can I create an image and use it as a background in a div and have the div use the size of that image as the dimensions for the div? If not can I insert an image into the div and have all the text and content of the div display on top of the image? Basically putting the image under all the content, but NOT as the background, but as an actual image to force the div to use the images size as its dimensions? Quote Link to comment https://forums.phpfreaks.com/topic/131654-can-you-use-an-image-background-to-define-the-dimensions-of-a-div/ Share on other sites More sharing options...
wildteen88 Posted November 6, 2008 Share Posted November 6, 2008 You can only have text over background images. Why do you want to the div to automatically adjust to your background image? Cant you hard code the width/height of the div? #my_div { background-image: ('my_background.gif'); background-repeat: no-repeat; width: 700px; height: 100px; } Quote Link to comment https://forums.phpfreaks.com/topic/131654-can-you-use-an-image-background-to-define-the-dimensions-of-a-div/#findComment-683843 Share on other sites More sharing options...
ifubad Posted November 6, 2008 Share Posted November 6, 2008 Q&A 2: not naturally. But you can try the following span { position: relative; color: #FF0000; top: -50px; left: -50px; } <div> <img src="image.jpg" height="100px"><span>Text</span> </div> Quote Link to comment https://forums.phpfreaks.com/topic/131654-can-you-use-an-image-background-to-define-the-dimensions-of-a-div/#findComment-683898 Share on other sites More sharing options...
dropfaith Posted November 6, 2008 Share Posted November 6, 2008 odd yea image size isnt flexible so i would just manually set the div size. to the size of the image #my_div { background-image: ('my_background.gif'); background-repeat: no-repeat; width: IMAGE WIDTH; height: IMAGE HEIGHT; } Quote Link to comment https://forums.phpfreaks.com/topic/131654-can-you-use-an-image-background-to-define-the-dimensions-of-a-div/#findComment-683945 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.