Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-17-2008, 04:34 AM   PM User | #1
silverskymedia
New Coder

 
Join Date: Jul 2004
Location: Utah, USA
Posts: 70
Thanks: 1
Thanked 0 Times in 0 Posts
silverskymedia is an unknown quantity at this point
Center Within Div Issue

Hello, I am having quite the brainfart trying to center some text. I've tried using a <div> and a <p>.

Any help would be appreciated.

http://silverskymedia.no-ip.com/portfolio/

Thanks.
silverskymedia is offline   Reply With Quote
Old 01-17-2008, 05:55 AM   PM User | #2
rmedek
Senior Coder

 
Join Date: Nov 2003
Location: Minneapolis, MN
Posts: 2,879
Thanks: 2
Thanked 65 Times in 56 Posts
rmedek is on a distinguished road
If you align the text to the right, you'll see where the problem is. The text on top of the centered text (your Constant Contact email form) is being positioned relatively, with a negative top value, to bring it up into the breadcrumb area. But positioning it relatively still reserves the space—for lack of a better term—so even though it's displayed out of the way it's still taking up space where it would normally be, preventing the text from being centered. Make sense?

Changing this:

Code:
<div style="float: right; position: relative; top: -27px; left: -30px;">
…to this:

Code:
<div style="float: right; margin: -27px 0 0 -30px;">
…should fix it. Hope that helps…
__________________
drums | web
rmedek is offline   Reply With Quote
Old 01-17-2008, 06:11 AM   PM User | #3
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello silverskymedia,
This works -
Code:
h1.menu {
 color:#ffcc66;
 text-align:center;
 border-bottom:1px solid #fff;
 font-size:2.4em;
 padding-left:10px;
 letter-spacing:.5em
}
h2 {
text-align: center;
}h3 {
 font-size:1.4em;
 color:#000
}
.slogan {
and
Code:
<div id="rightcolumn">
<div id="breadcrumb">
  <p>
    <a href="/" style="text-decoration: none;">Home</a> | &nbsp;Portfolio
  </p>
  <div style="float: right; position: relative; top: -27px; left: -30px;">
  <!-- BEGIN: Constant Contact HTML for Send Page to Friend  -->
  <div style="float: left; position: relative; top: 7px;"><img src="/images/Email.gif" border="none"></div>&nbsp;<a href="/share/default.asp?url=http://silverskymedia.no-ip.com/portfolio/Default.asp?" class="sendToFriend">Send page to a friend</a>
  <!-- END: Constant Contact HTML for Send Page to Friend  -->
</div>
</div>


    <h2>This should be centered, but it's not!!!</h2>


<!-- End Right Column -->

<div class="clear"></div>
</div>
I only used h2 because it's not a paragraph...


Plenty of things to fix if you look at that in the validator!!
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 01-17-2008, 06:31 AM   PM User | #4
silverskymedia
New Coder

 
Join Date: Jul 2004
Location: Utah, USA
Posts: 70
Thanks: 1
Thanked 0 Times in 0 Posts
silverskymedia is an unknown quantity at this point
Wow, thanks for the responses. rmedek, you were right. using the float did the trick. Thanks for the help and I hope I can remember this in the future.
silverskymedia is offline   Reply With Quote
Old 01-17-2008, 06:35 AM   PM User | #5
rmedek
Senior Coder

 
Join Date: Nov 2003
Location: Minneapolis, MN
Posts: 2,879
Thanks: 2
Thanked 65 Times in 56 Posts
rmedek is on a distinguished road
No problem, but note it wasn't the float, it was the negative margins versus relative positioning.
__________________
drums | web
rmedek is offline   Reply With Quote
Old 01-17-2008, 05:36 PM   PM User | #6
silverskymedia
New Coder

 
Join Date: Jul 2004
Location: Utah, USA
Posts: 70
Thanks: 1
Thanked 0 Times in 0 Posts
silverskymedia is an unknown quantity at this point
OK, I'll note that.
silverskymedia is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:18 PM.


Advertisement
Log in to turn off these ads.