Cant get div in right position
#1
Posted 04 February 2006 - 03:05 PM
http://www.retrodesi...k/Gallery1.html
the problem is: each of the names are in there own divs and i would like them to be positioned 10px up from the surrounding box and central, but i cant seem to get this to line up correct.
anyone have any suggestions?
thanks for any help offered
#2
Posted 04 February 2006 - 03:59 PM
CSS:
h3 {
font: 12px verdana, arial, sans-serif;
border: 1px solid #000;
width: 150px;
text-align: center;
position: relative;
bottom: 10px;
left: -75px;
margin: 0 0 0 50%;
}
XHTML:
<h3>Text</h3>
That's just off the top of my head, so if there are any issues let me know.
Also, you are using way too many divs in your layout! 90% of the divs you're using are pointless and could be done without. Use the header tag for headers (duh) or short text like you're using; it makes the code cleaner and much shorter.
#3
Posted 04 February 2006 - 04:06 PM
I am aware that there are too many divs and that it doesnt show up well in safari/firefox but as ths is my first site i am learnig as i go along, ideally want it to be up and running and then will look at ways to improve the site.
do i just insert the header tag as i would a div i the html?
thanks
#4
Posted 04 February 2006 - 04:12 PM
#5
Posted 04 February 2006 - 07:21 PM
Greg, can you tell me how i can get a border around the images? i have tried several times and can get now where with this?
just a few questions regarding the new code you posted, why is left -75px? and why is margin: 0 0 0 50%;? thanks
thanks
Edited by donkeymusic, 04 February 2006 - 07:22 PM.
#6
Posted 04 February 2006 - 07:50 PM
To give your images a border, assign them a class. A class can be used multiple times on a page, whereas an ID is unique and can only be used once on a page.
CSS:
.borderimage {
border: 1px solid #000;
}
XHTML:
<img src="blah.jpg" alt="blah" class="borderimage" />
For your other question... If the div which contains the header has a set height, you can replace "bottom: 10px;" with "top: XXpx", where XX is the distance from the top of the containing div.
#7
Posted 07 February 2006 - 03:00 PM
greg, on Feb 5 2006, 12:50 AM, said:
To give your images a border, assign them a class. A class can be used multiple times on a page, whereas an ID is unique and can only be used once on a page.
CSS:
.borderimage {
border: 1px solid #000;
}
XHTML:
<img src="blah.jpg" alt="blah" class="borderimage" />
For your other question... If the div which contains the header has a set height, you can replace "bottom: 10px;" with "top: XXpx", where XX is the distance from the top of the containing div.
greg, i made the change to top 75px which i worked out would be correct but now the top row of names are runnig through the bottom images, any ideas?
#8
Posted 07 February 2006 - 03:21 PM
#9
Posted 08 February 2006 - 04:29 AM
http://photobucket.com/albums/v489/donkeym...rent=screen.jpg
The code i have is
<div id="content"> <div id="card_1"> <div id="galleryphoto"><img src="galleryimages/scarface_red.jpg" class="img" alt="Scarface_Red"></div> <div id="galleryphotoname">Scarface Red</div> </div> <div id="card_2"> <div id="galleryphoto"><img src="galleryimages/scarface_buff.jpg" class="img" alt="Scarface_Buff"></div> <div id="galleryphotoname">Scarface Buff</div> </div> <div id="card_3"> <div id="galleryphoto"><img src="galleryimages/Bruce_Lee.jpg" class="img" alt="Bruce_Lee"></div> <div id="galleryphotoname">Bruce Lee</div> </div> <div id="card_4"> <div id="galleryphoto"><img src="galleryimages/scarface_white.jpg" class="img" alt="Scarface_White"></div> <div id="galleryphotoname">Scarface White</div> </div> <div id="card_5"> <div id="galleryphoto"><img src="galleryimages/scarface_1.jpg" class="img" alt="Scarface_1"></div> <div id="galleryphotoname">Scarface 1</div> </div> <div id="card_6"> <div id="galleryphoto"><img src="galleryimages/scarface_2.jpg" class="img" alt="Scarface_2"></div> <div id="galleryphotoname">Scarface 2</div> </div>
and the css is
#galleryphoto {
background-color: #ffffff;
text-align: center;
margin-top:10px;
}
#galleryphotoname{
font: 14px verdana, arial, sans-serif;
border: 1px solid #000;
width: 180px;
text-align: center;
position: relative;
top: 170px;
height: 20px;
left: -75px;
margin: 0 0 0 50%;
}
.img {
border: 1px solid #000000;
}
cheers
#10
Posted 08 February 2006 - 07:54 AM
Here's an alternative: Since each image is the same height, you can simply give a top margin to the header text. Make sure to add padding: 0; in case any padding is being cascaded down in the CSS.
#11
Posted 08 February 2006 - 03:45 PM
greg, on Feb 8 2006, 12:54 PM, said:
Here's an alternative: Since each image is the same height, you can simply give a top margin to the header text. Make sure to add padding: 0; in case any padding is being cascaded down in the CSS.
do you mean the <div id="card_1">,<div id="card_2"> they do have a class set in css.
why no alt tags? i thought that was so that when hovered over the picture it showed the name? or have i got alt tags mixed up with something else?
header text? dont think i have this,
would it help if i sent my whole file system to you?
thanks
#12
Posted 08 February 2006 - 05:56 PM
In html/css, the id attribute is meant to specify a unique id, sort of like in the real world. People have to carry around their own personal id with their picture on it, so people (mainly cop's), and certain businesses that have any kind of security (such as the CIA), can tell you apart from Joe. Same concept applys here.
Change the "id" part to "class" in the html, and the "#" to a "." in the css, and you'll be done with that issue.
As for the alt tags, i think greg went cross-eyed for a sec, because they are in the <img> tags where the belong (that or i'm going blind).
p.s. I know the "CIA" isn't a business, but good luck getting into one of their headquarters without the right id...
Edited by rc69, 08 February 2006 - 05:57 PM.
#13
Posted 08 February 2006 - 06:01 PM
rc69, on Feb 8 2006, 10:56 PM, said:
In html/css, the id attribute is meant to specify a unique id, sort of like in the real world. People have to carry around their own personal id with their picture on it, so people (mainly cop's), and certain businesses that have any kind of security (such as the CIA), can tell you apart from Joe. Same concept applys here.
Change the "id" part to "class" in the html, and the "#" to a "." in the css, and you'll be done with that issue.
As for the alt tags, i think greg went cross-eyed for a sec, because they are in the <img> tags where the belong (that or i'm going blind).
p.s. I know the "CIA" isn't a business, but good luck getting into one of their headquarters without the right id...
but those two ids are different though, i thought class was where you were using like ids? thats why i presumed he meants the ones used for the cards?
bit confused with classes and have read about them before and couldnt get head around them
#14
Posted 08 February 2006 - 06:11 PM
But look at the following block:
<div id="card_5"> <div id="galleryphoto"><img src="galleryimages/scarface_1.jpg" class="img" alt="Scarface_1"></div> <div id="galleryphotoname">Scarface 1</div> </div> <div id="card_6"> <div id="galleryphoto"><img src="galleryimages/scarface_2.jpg" class="img" alt="Scarface_2"></div> <div id="galleryphotoname">Scarface 2</div> </div>In every single interation of your card sections, you repeat the id's i showed in the last post. Classes are nothing special, think of the way you're currently using the id's. Same concept goes for classes.
Edited by rc69, 08 February 2006 - 06:12 PM.
#15
Posted 08 February 2006 - 08:40 PM
rc69, on Feb 8 2006, 11:11 PM, said:
But look at the following block:
<div id="card_5"> <div id="galleryphoto"><img src="galleryimages/scarface_1.jpg" class="img" alt="Scarface_1"></div> <div id="galleryphotoname">Scarface 1</div> </div> <div id="card_6"> <div id="galleryphoto"><img src="galleryimages/scarface_2.jpg" class="img" alt="Scarface_2"></div> <div id="galleryphotoname">Scarface 2</div> </div>In every single interation of your card sections, you repeat the id's i showed in the last post. Classes are nothing special, think of the way you're currently using the id's. Same concept goes for classes.
i will look into changing that, although i am sure that the id=cards are not unique they all use the same css settings
#16
Posted 08 February 2006 - 09:56 PM
If you can e-mail me the entire file I would be able to clean it up for you: greg.ny@gmail.com
Edited by greg, 08 February 2006 - 09:56 PM.
#17
Posted 08 February 2006 - 10:02 PM
id="card_1"
id="card_2"
...
id="card_6"
All of which are unique since they have a different number on the end. None of which will be affected by the "#card" selector which i don't see in your CSS either.
#18
Posted 09 February 2006 - 05:06 AM
greg, on Feb 9 2006, 02:56 AM, said:
If you can e-mail me the entire file I would be able to clean it up for you: greg.ny@gmail.com
would really appreciate that greg, thanks
#19
Posted 09 February 2006 - 03:24 PM
I took out all the pointless divs and replaced them with a table. You can see how less cluttered it is now:
HTML before:
<div id="card_1"> <div id="galleryphoto"><img src="galleryimages/scarface_red.jpg" class="img" alt="Scarface_Red"></div> <div id="galleryphotoname">Scarface Red</div> </div> <div id="card_2"> <div id="galleryphoto"><img src="galleryimages/scarface_buff.jpg" class="img" alt="Scarface_Buff"></div> <div id="galleryphotoname">Scarface Buff</div> </div> <div id="card_3"> <div id="galleryphoto"><img src="galleryimages/Bruce_Lee.jpg" class="img" alt="Bruce_Lee"></div> <div id="galleryphotoname">Bruce Lee</div> </div> <div id="card_4"> <div id="galleryphoto"><img src="galleryimages/scarface_white.jpg" class="img" alt="Scarface_White"></div> <div id="galleryphotoname">Scarface White</div> </div> <div id="card_5"> <div id="galleryphoto"><img src="galleryimages/scarface_1.jpg" class="img" alt="Scarface_1"></div> <div id="galleryphotoname">Scarface 1</div> </div> <div id="card_6"> <div id="galleryphoto"><img src="galleryimages/scarface_2.jpg" class="img" alt="Scarface_2"></div> <div id="galleryphotoname">Scarface 2</div> </div>
Now:
<table id="gallery"><tr><td> <img src="galleryimages/scarface_red.jpg" alt="Scarface_Red" /> <p>Scarface Red</p> </td><td> <img src="galleryimages/scarface_buff.jpg" class="img" alt="Scarface_Buff" /> <p>Scarface Buff</p> </td><td> <img src="galleryimages/Bruce_Lee.jpg" class="img" alt="Bruce_Lee" /> <p>Bruce Lee</p> </td><td> <img src="galleryimages/scarface_white.jpg" class="img" alt="Scarface_White" /> <p>Scarface White</p> </td></tr><tr><td> <img src="galleryimages/scarface_1.jpg" class="img" alt="Scarface_1" /> <p>Scarface 1</p> </td><td> <img src="galleryimages/scarface_2.jpg" class="img" alt="Scarface_2" /> <p>Scarface 2</p> </td></tr></table>
CSS got cleaner too. Before:
div#card_1,
div#card_2,
div#card_3,
div#card_4,
div#card_5,
div#card_6{
margin: 0px;
width: 240px;
height: 200px;
background-color: #ffffff;
border: 1px solid #000000;
}
div#card_1{
float: left;
}
div#card_2{
float: left;
margin-left: 9px;
margin-right: 9px;
}
div#card_3{
float: left;
}
div#card_4{
float: left;
margin-top:10px;
}
div#card_5{
float: left;
margin-left: 9px;
margin-right: 9px;
margin-top:10px;
}
div#card_6{
float: left;
margin-top:10px;
}
#navigation{
color: #000000;
font-family: geneva, Arial, sans-serif;
font-size: 12px;
text-align: center;
width:700px;
}
#galleryphoto {
background-color: #ffffff;
text-align: center;
margin-top:10px;
}
#galleryphotoname{
font: 14px verdana, arial, sans-serif;
border: 1px solid #000;
width: 180px;
text-align: center;
position: relative;
top: 170px;
height: 20px;
left: -75px;
margin: 0 0 0 50%;
}
.img {
border: 1px solid #000000;
}
And now:
#gallery {
clear: both;
width: 700px;
}
#gallery td {
width: 165px;
height: 165px;
padding: 0;
margin: 0 5px 0;
text-align: center;
}
#gallery img {
padding: 0;
margin: 0;
}
#gallery p {
vertical-align: bottom;
margin: 5px 0 10px;
padding: 0;
background: #fff;
font: 14px verdana, arial, sans-serif;
}
Again, this is just a sketchy 10-minute job just to get you rolling. Work on it from here and fix it up to suit your needs.
Oh yes, and to make the text be on the bottom of its container you need to use "vertical-align:bottom;" as I did above. I forgot to mention that earlier on.
Edited by greg, 09 February 2006 - 03:25 PM.
#20
Posted 11 February 2006 - 03:47 PM
Hoot
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
