[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Center 2 divs within block (fluid)

Posted on 2011-10-26
5
Medium Priority
?
194 Views
Last Modified: 2012-05-12
I am working on developing a site here:       goo.gl/kR946 - I am working on making this in to a responsive website. My area I cant get is:

The main nav "Discover" and "Engage" - What is the best way to center those 2 elements with in the diagonal block?

I tried margin:0 auto and tried setting a width as well, and tried to inherit but that didnt work.

Ryan
0
Comment
  • 2
  • 2
5 Comments
 
LVL 30

Expert Comment

by:LZ1
ID: 37032343
The main problem is that they are both different widths. The engage element is trying to center off of the discover width. You'll have to set a separate width for the Engage parent
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 37032427
So even know I have this declaring both:

.nav_header {
  background: url("../images/nav_header.png") no-repeat scroll -454px 0 transparent;
  float: left;
  height: 40px;
  line-height: 40px;
  margin: 0 2.96371% 31px 0;
  width: 42.8711%;
}

The % render differently?

Ryan
0
 
LVL 30

Accepted Solution

by:
LZ1 earned 2000 total points
ID: 37032445
No. It's rendering the same, however it's because the text inside are 2 different widths.
Discover is 8 letters
Engage is 6 letters

That is going to make a huge difference in spacing, as you can see. I would class both of them and assign them widths as close as possible to their actual widths.
0
 
LVL 12

Expert Comment

by:zappafan2k2
ID: 37032466
I'm not so sure about the different widths being a problem.

You're trying to get the words "discover" and "engage" to be centered within their respective parent divs, right?  One thing to remember is that "inherit" is ignored by IE.

Can you try this?
1. Replace "width: inherit" with "text-align: center" for .nav_header_wrap in style.css (around line 137)
2. Remove "float: left" for .nav_item in style.css (around line 150)

See if that works.
0
 
LVL 1

Author Closing Comment

by:catonthecouchproductions
ID: 37038783
Separating the 2 with their own class, worked perfect!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question