I searched the web for solutions but none centered this horizontally on the page. I tried margin-right: auto; and margin-left: auto; and tried margin 0 auto: What's the solution? Thanks. .container10 { border:1px solid #000000; background: #00FF00; padding:0px 0px 0px 0px; width:980px; height:264px; margin:0px 0px 0px 0px; } Code (markup):
I'm pretty sure you didn't http://lmgtfy.com/?q=center+div+horizontally Code (markup): Golly, so many results Bonus: How to use a search engine http://www.kidzworld.com/article/1900-search-engine-tutorial Code (markup):
Wow. You're being kind of a jerk. The searches I found orginally didn't work for me that why I've asked for help here. Any other help from any one else would be appreciated.
I'm being kind of a jerk because your question could be EASILY fixed by searching. Well, seems you are not going to do work on your own, so here: Replace your margin with this margin:0 auto; Here is a jsfiddle, so you can see it working http://jsfiddle.net/MB3eA/ If it doesn't on your site... there would be something else prohibiting it
I did search. I did find margin: 0 auto; I added it and it still didn't work, before I ever posted here. So, I thought I'd get help with guidance as to what I might need to look at in regard to "be something else prohibiting it". So, I am doing the work on my own. Why don't you search online to find an ego deflater, and follow the directions there.
Is it my problem that you don't show us the whole code of your site? If you had posted that, I wouldn't be such a jerk, because before I respond, I usually try it out. But now, all I see is some css for a class called .container10 Since I am no psychic, I cannot see the rest of your code, so I can't possibly know if there is something prohibiting the horizontal centring.
No, it's not your problem that I have a code issue, your problem is that you jump to negative conclusions, enjoy putting people down, enjoy being sarcastic, and assume they're not telling the truth. Instead of simply saying in the beginning "why don't you show us more code", which would be helping people in this forum, insteading of using it as a place to make yourself feel superior. I'm sure when the sun rises tomorrow my issue will be resolved, yours probably not. I'll post this on another forum.
A container with a fixed width and height? Bad idea. Nulling margins and padding in like that? Bad idea. If your code is this bad all along, no doubt you'll have issues. You should check if its parent is floated. If so, you cannot center it.
If you are that thin skinned, you're lucky I didn't reply to this one -- since my response would have said what Wiicker95 did, but with more expletives, interjections and general 'half assed code' bashing. Though usually I don't take the LMGTFY approach because it pisses me off when people make that assumption as well. You wouldn't be asking if the solutions you had found didn't work! It's also funny to see some users being more acerbic than me to the nubes... The fixed width ALONE would set me to full froth given it's automatically accessibility trash... much less the fixed height which treads into serious herpaderp territory in all but the rarest of circumstances. But again, we can't tell without seeing more, since CSS without the HTML it's applied to, the HTML around it, and the CSS of the things applied to all the rest is pretty much useless.
I'm no expert at this, my css is also messed up like crash. But when I'm stuck like this, can't center divs and shit, like wiicker95 said, your parents is floated pun intended. Then smack some new divs on top of your .container10 div and class it and put clear:both;. It's not advisable to smack things up, but at least I have an excuse. Now smack that piece up and set your hopes high and promise that on your next project you will carefully code it clean and tidy. Promise. I like to start my css feeling tidy, clean and hoping that at the end it will structure beautifully. But then during design, I will hammer everything I got till that navigation appears like I want it to be. Then it got messy and I thought of starting over. The feeling of starting over. Fresh. Like standing on top of a mountain in New Zealand. I'm trash talking am I?
This is exactly why people shouldn't use photoshop and paint arsty stuff with it when building websites. Some stuff you design just aren't web deployable, no matter how neat and pretty they might be. Although it seems like you're crapping nonsense, your post actually makes perfect sense (well, at least the context): you mention one of the most common problems when it comes to web designing! Painting such designs without having established a semantic markup along with web deployable layouts is a road to failiure in any case. This is unfortunately why those nutcrackers on themeforest and other similar sites manage to sell their useless artwork to people that don't know better.
Leave the themeforest nutcrackers be. DP has got more nutcrackers than nuts. Why the hell more tools than content? Are they using the tools as their contents? It is up to us to set things straight. It all has to start from within................... (High...How are you?)
There are many solutions in the Internet. Try to search for it again. But I think, it will be helpful if you use margin-left; and margin-top;
Or you can just do it really easy like this: margin-right: auto; margin-left: auto; And remember! body { margin-top: 0; } unless you want a top-margin on your website!