May 21, 200917 yr I am using Dreamweaver CS4 and I can't seem to figure out how to place and position images where ever I want them? Is there some sort of secret? If anyone can help it would be awesome! Thanks
May 22, 200917 yr Do you mean positioning as in aligning them to the left/right/center or positioning as in 50px from the left/250px from the top?
May 22, 200917 yr There are many ways to approach this, here's one... Give your image a CSS class name... <img src="myimage.jpg" alt="" class="myimage" /> Now write the CSS... .myimage { float: left; /* aligns left */ margin-top: 250px; /* top margin */ margin-left: 50px; /* left margin */ }
May 23, 200917 yr Author Here is a little more detail I am making a contact page, and I have all my contact information on the left and I want to put a question mark image just to the right of the information. When I try to do this is makes gaps in my information, as if the images was pushing the text out of the way and was part of the text.
May 23, 200917 yr Author There are many ways to approach this, here's one... Give your image a CSS class name... <img src="myimage.jpg" alt="" class="myimage" /> Now write the CSS... .myimage { float: left; /* aligns left */ margin-top: 250px; /* top margin */ margin-left: 50px; /* left margin */ } Thanks you so much, this helped A LOT! I got it to work. If I need the image to go behind text how to I do that? because right now if I get to close it pushes the text out of the way.
May 23, 200917 yr you need to add these css attributes position:relative; (remove it from the document flow, but position it relative to where it occurs, a positioning attribute is required to use the z axis) z-index:-10; (this it's third dimensional or layer position on the page, x is across, y is vertical and z is forwards and backwards - Default is 0 so we need a negative value) Now you can either use the margin properties like you have been doing, or you can make use of the top: left: bottom: right: properties to position it accordingly So something along these lines .myimage { position:relative; /* Declare how we want to position it, this cancels out the ability to 'float' elements, careful if you're combining relatively positioned elements with floated elements */ top: 250px; /* position relative to the top - y axis */ left: -50px; /* position relative to the left - x axis */ z-index: -10 /* z-axis */ }
May 23, 200917 yr Author So messing around with the position stuff you said I found that I had to use "position:absolute" instead of relative. I don't really know what either one actually does, so if anyone could break it down that would be awesome.
May 23, 200917 yr Straight of W3Schools: static - Default. An element with position: static always has the position the normal flow of the page gives it (a static element ignores any top, bottom, left, or right declarations) relative - An element with position: relative moves an element relative to its normal position, so "left:20" adds 20 pixels to the element's LEFT position absolute - An element with position: absolute is positioned at the specified coordinates relative to its containing block. The element's position is specified with the "left", "top", "right", and "bottom" properties fixed - An element with position: fixed is positioned at the specified coordinates relative to the browser window. The element's position is specified with the "left", "top", "right", and "bottom" properties. The element remains at that position regardless of scrolling. Works in IE7 (strict mode) Try out some of the Demo's http://www.w3schools.com/Css/pr_class_position.asp
Create an account or sign in to comment