Solved

How to center content?

Posted on 2013-01-21
18
352 Views
Last Modified: 2013-01-21
How can I get all of the content below to center?  

In the div mc_embed_signup, why does text-align:center have no effect?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<title></title>
	</head>
	<body>

<!-- Begin MailChimp Signup Form -->
<link href="http://cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<div id="mc_embed_signup" style="background:#f8f8f8;text-align:center;width:500px;">
<form action="" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<label for="mce-EMAIL">Just sign up to our newsletter to receive your free copy of our latest ebook and content.</label>
<input type="text" value="" name="FNAME" class="email" id="mce-FNAME"placeholder="first name" required style="width:200px;">
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required style="width:200px;"><div><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" style="width:200px;"></div>
</form>
</div>
<!--End mc_embed_signup-->
	</body>
</html>

Open in new window

0
Comment
Question by:brettr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 4
  • +1
18 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38802168
Try adding "margin: auto;" to your style:

<div id="mc_embed_signup" style="background:#f8f8f8;text-align:center;width:500px; margin: auto;">

Open in new window

0
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 125 total points
ID: 38802172
If you are trying to center it in the page then do it this way:

<div id="mc_embed_signup" style="background:#f8f8f8;text-align:center;width:500px; margin:auto;">

If that does not solve it post a link to the page so we can see if the obsolete doctype or something else is part of the problem.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38802179
Sorry kaufmed, I should have refreshed; or typed faster.

Cd&
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:brettr
ID: 38802182
Sorry - it's actually the content in the gray box I'd like to center, not center against the page.  Right now, the interior content is left aligned.
0
 
LVL 30

Assisted Solution

by:IanTh
IanTh earned 125 total points
ID: 38802188
you might need a div within mc_embed

and in css set the inner div as centered and put the form in the inner div

and mc-emded in css as 1024 pixels  

so

<!-- Begin MailChimp Signup Form -->
<link href="http://cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<div id="mc_embed_signup" style="background:#f8f8f8;text-align:center;width:500px;">
<div id="inner_mc" style="text-align:center;">
<form action="" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<label for="mce-EMAIL">Just sign up to our newsletter to receive your free copy of our latest ebook and content.</label>
<input type="text" value="" name="FNAME" class="email" id="mce-FNAME"placeholder="first name" required style="width:200px;">
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required style="width:200px;"><div><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" style="width:200px;"></div>
</form>
</div>
</div>
<!--End mc_embed_signup-->
      </body>
</html>
0
 

Author Comment

by:brettr
ID: 38802205
@IanTh

I tried the code you pasted but don't see that anything is being centered.
0
 
LVL 30

Expert Comment

by:IanTh
ID: 38802217
do you have a separate css file ?
0
 

Author Comment

by:brettr
ID: 38802228
No.  I'm trying the code stand alone as I pasted it for the simplest scenario.
0
 
LVL 30

Expert Comment

by:IanTh
ID: 38802321
what browser are you testing it on I think there used to be a align:center for a div but that's deprecated
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 38802332
What "gray box"? I see a gray button. Are you referring to the text, "Just sign up..."? If so, have you tried adding a text-align to the label instead?

<label for="mce-EMAIL" style="text-align: center;">Just sign up to our newsletter to receive your free copy of our latest ebook and content.</label>

Open in new window

0
 

Author Comment

by:brettr
ID: 38802354
A gray box surrounds the content.  Not sure why you can't see it.   background:#f8f8f8 creates it.  I've attached a screenshot with preview in Taco HTML Edit.

Adding that style to the label does center the text.  But how do I also center the two input boxes and button?

preview
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38802472
Ah. Opera is not showing it for some reason--I assume the style isn't quite proper--but I can see it in IE. Have you tried the <label> suggestion?

Screenshot
[edit]

It is there in Opera. It's just so light that it's easy to miss!

[/edit]
0
 

Author Comment

by:brettr
ID: 38802495
You can see in your screenshot that the input boxes and button still aren't centered.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38802591
preview in Taco HTML Edit

Preview mode in a tool is not the place to assess presentation.  

It needs to be in a page and rendered by a browser.  Just looking at a code fragment in a  tool will not tell you how it renders in the real world. You also have all kinds of ids and classes. Is the tool applying those or just what is in the fragment?

Cd&
0
 

Author Comment

by:brettr
ID: 38802641
What do you mean by "those"?

It looks the same in the tool or in a browser.
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
ID: 38802660
Use the 2nd <div> approach suggested by IanTh, but put a "margin: auto;" and a width on that <div>:

...
<div id="mc_embed_signup" style="background:#f8f8f8;text-align:center;width:500px;">
<div style="margin: auto; width: 50%;">
...
</div>
</div>
...

Open in new window

0
 
LVL 30

Expert Comment

by:IanTh
ID: 38802674
I think on mc-emdeb you will need to setup padding to push it to the middle
0
 
LVL 30

Expert Comment

by:IanTh
ID: 38804147
padding will work as well if you have a div that is say 100 pixels wide and you add padding of 100 pixels the elements are 200 from the left assuming float left
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

688 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