HTML - Centering A Div Block That Works In Most Browsers
I was experimenting with the css of my div block and idk if this code would work in most browsers and screen resolution. if you guys know of an alternative code that would align my div block to the center that would work on most browsers AND screen resolution, please help me. thank you
Quote: <div style="margin:0px auto;width:200px;display:block;">blah blah</div> Similar TutorialsHi I have tried a lot of things and search the internet for hours regarding this matter... My image background doesn't reapeat in Internet explorer however works fine in any other browsers such as google chrome and firefox. Can you please help me get this fixed? I am new to xhtml and css and really it's really frustrating having this kind of problem. Thank you Website Link: www.pjrazon.co.uk/newlayout/index.html screenshots if it helps: CSS: @charset "utf-8"; * { margin: 0px; padding: 0px; } body { background-color: #CCCCCC; } a:link { color: #ffffff; text-decoration: none; } a:visited {text-decoration: none;} a:hover {color: #b23937;} a:active {text-decoration: none;} #wrapper { width: 1151px; margin-right: auto; margin-left: auto; border-right-width: thin; border-left-width: thin; border-right-style: solid; border-left-style: solid; border-right-color: #999999; border-left-color: #999999; } #wrapper #logo { height: 120px; width: 1151px; } #wrapper #navigation { background-image: url(../images/nav.home.gif); height: 32px; } #wrapper #navigation #navlabel { color: #FFFFFF; padding-top: 5px; padding-left: 125px; } #wrapper #navigation #navlabel #nav li { display:block; width:100px; float:left; list-style:none; } #wrapper #header { height: 391px; background-image: url(../images/welcome.jpg); } #wrapper #mainContent { height: 384px; background-image: url(../images/maincontent.jpg); width: 1151px; } #wrapper #bodyArea #footer { background-image: url(../images/footer.jpg); height: 73px; clear: both; } #wrapper #bodyArea { background: url(../images/bg_bodyarea.jpg) repeat-y; } #wrapper #bodyArea #mainContent #content { display:block; width:400px; float:left; } #wrapper #bodyArea #mainContent #contentwrapper { padding-left: 140px; padding-top: 70px; } HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Perfect Vision</title> <link href="css/layout.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper"> <div id="logo"><img src="images/header.jpg" alt="logo" /></div> <div id="navigation"> <div id="navlabel"> <ul id="nav"> <li><a href="homepage.html">Home</a></li> <li><a href="profile.html">Profile</a></li> <li><a href="portfolio.html">Portfolio</a></li> <li><a href="contact.html">Contact</a></li> </ul> </div> </div> <div id="header"></div> <div id="bodyArea"> <div id="mainContent"> <div id="contentwrapper"> <div id="content"> <p>August 10 2010</p> <p> </p> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam semper turpis in tortor interdum sed mattis lectus mollis. Pellentesque laoreet quam et mauris feugiat sit amet eleifend turpis imperdiet. Praesent condimentum libero vitae massa imperdiet pellentesque. Vestibulum et risus dolor, ac tincidunt velit. Maecenas lobortis diam tellus. Suspendisse auctor, velit ut imperdiet semper, erat orci pharetra tortor, venenatis vulputate metus eros ut felis. Cras ullamcorper odio sed felis ornare ultricies. Phasellus porta adipiscing aliquet. Aenean ligula tellus, blandit a pulvinar in, fermentum a erat. Sed arcu nisl, porta eu vestibulum at, luctus sed tellus. Aenean eget quam justo, quis ultricies ante. Vivamus tempor sollicitudin augue ut rhoncus. Sed odio mauris, imperdiet ut elementum vitae, dapibus at quam. Nullam in aliquam sem. Fusce consectetur laoreet elit, non consequat nunc tempus nec. Cras at enim ipsum. Praesent ipsum purus, tempus non sagittis volutpat, fringilla eget mi. Maecenas sed elit est. Morbi facilisis purus eget nunc tincidunt iaculis mattis quam pellentesque. </p> <p> Sed tortor leo, laoreet sit amet mattis a, fermentum in ligula. Sed tempor lacus a lorem fermentum fermentum semper nunc sagittis. Vivamus et est porta purus mollis cursus eget in ante. Sed lacinia, diam in tempor suscipit, turpis enim posuere turpis, sit amet vestibulum quam nulla id elit. Vivamus ultricies tempus mi, non consequat velit mollis id. Curabitur vehicula, turpis id tempor condimentum, sem nulla molestie enim, vel commodo metus ipsum non nisi. Aliquam erat volutpat. Fusce venenatis porttitor massa eget suscipit. Sed purus turpis, iaculis id sollicitudin id, vulputate sit amet velit. Suspendisse sed velit non tellus eleifend venenatis vehicula ut elit. Integer sit amet ullamcorper nulla. </p> <p> Vestibulum dictum ante eu nisl ornare tincidunt. Etiam id risus mauris. Duis nec turpis in neque porttitor euismod sed id odio. Sed molestie urna a magna fermentum egestas. Nulla facilisi. Quisque risus neque, sodales pulvinar rhoncus a, lacinia eget neque. Vivamus vel malesuada nisl. Proin mollis tempor felis id dapibus. Morbi velit mi, aliquet sed malesuada et, blandit vitae eros. Nulla nec lorem quam, eu aliquam sapien. Quisque venenatis, enim non ultricies lobortis, lectus dolor consectetur nulla, eu tincidunt metus enim vitae libero. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent sit amet neque eu libero commodo condimentum. Fusce hendrerit diam sed libero lacinia nec adipiscing massa posuere. Pellentesque eget libero risus, eget venenatis metus. Morbi quis dolor enim. Cras orci orci, ultrices nec consectetur sed, auctor non leo. Aliquam nec sem erat. Nam ut nunc sed leo tempor pretium. Maecenas sit amet tortor a neque congue iaculis eu in ipsum. </p> </div> </div> </div> <div id="footer"></div> </div> </div> </body> </html> I have created a custom html dropdown menu for my site. The thing is it looks perfect in Firefox 5.0 (for me it does anyway) and works just as expected but in other browsers such as Opera 10.60, Chrome 5.0.375.125, it doesn't work properly. and it works semi ok in IE 8. For example if I hover over one of the menu buttons in opera or chrome there is meant to be a drop down box, this doesn't show in Opera or chrome but does in IE? You can view the menu on my test site - http://www.themidwiferysanctuary.com/testsite/ There is more to the menu, you can use the following log in - Username: Jade Password 130489 Does anyone have any thoughts on how to get the dropdown compatiable with all (or most) browsers? I would post the code but it won't let me even when using the code tags.......... If you want to see the javascript code then please just let me know. Im not sure any of the above makes sense?? Thank you, Jade I'm trying to create a page where there is a centered background image, and two div's, one on the left and one on the right, all aligned properly. I tested it by syncing it to my website, and I -think- it displays correctly. However it definitely does not display correctly in Dreamweaver, as in Dreamweaver my central background image is slanted to the left for some reason. Can someone please check my code to make sure it has this layout? (Background image centered, with one section on left and one on right, two sections has same size and same distance from background image) But in Dreamweaver it shows up like this, so I'm worried it might not display correctly on computers with different resolutions: Code: <!DOCTYPE HTML> <html> <head> <!-- Create container type object containing background image with interactive image links layered on top. --> <!-- Objects are centered on screen. Sub-image positions are relative to container --> <style> #container { display: block; margin-left: auto; margin-right: auto; position: relative; border:none; width: 380px; height: 633px; background-image: url("pictures/mainmenu.png"); background-position:center; } #container img { position: absolute; border:none; left: 65px; width: 245px; height: 53px; } <!-- the three buttons --> #image1 {top: 225px} #image2 {top: 300px} #image3 {top: 375px} </style> <meta charset="utf-8"> <LINK href="style.css" rel="stylesheet" type="text/css"> <title>Main Playlist</title> </head> <body> <br> <br> <div id="wrap"> <div id="left"><a href="ContactInfo.html" style="color:#000">Profile</a></div> <div id="right">Upcoming works</div> <div id="container"> <a href="song1.html"><img src="pictures/button-hualuowuyuan.png" alt="song1" id="image1" /></a> <a href="song2.html"><img src="pictures/button-river.png" alt="song2" id="image2" /></a> <a href="song3.html"><img src="pictures/button-snow.png" alt="song3" id="image3" /></a> </div> </div> </body> </html> CSS: Code: @charset "utf-8"; /* CSS Document */ body { margin:10px; padding:10px; background-image: url(pictures/audigrandpiano.jpg); background-repeat:no-repeat; background-position:right bottom; } img.center{ display: block; margin-left: auto; margin-right: auto; } #wrap { position:relative; min-height:100%; } #left { float:left; width:300px; height:500px; text-align:center; } #right { float:right; width:300px; height:500px; text-align:center; } Really appreciate it Hi! I have a problem with a div in my website. As you can see, the text goes out of the div block. The text is in <pre> tags! I noticed that first the problem was because text isn't seperated, but it still goes out of the block. In FF I can use <pre width>, but this doesn't work in IE. How can I "force" the text in the block? Hello, i got a css theme, that i tried with tumblr, it didn't work, seems like that i have missed something. I can't upload, or post anything, ...well i can but from the CSS file, and it's kinda annoying. here's the theme. http://www.2shared.com/document/jTGY...e_tumblr_.html I tried to create the blocks, the following ones : http://skeedio.com/tutorials/web-des...tumblr-themes/ But it did nothing, can anyone help/edit me ? please or can tell me what i've missed ? can i create the block from the css ? it seems that tumblr is more html...i'm newbie sorry ) Hello all. Is it possible to block multiple words in a search box using html or javascript? A search box on my own site. Example: writing "bad" in the search box will receive no results. Hoping for an answer Harold Dear all, How can I get a block of text to appear in its own coloured box? I want to display some BlitzBasic code like this... ... but at the moment, I'm doing it like this, padding it out with spaces... Code: <p><span style="background-color:#D1D1FF;"><tt> Graphics3D 640,480 <br /> SetBuffer BackBuffer() <br /> cam=CreateCamera() <br /> light=CreateLight() <br /> cube=CreateCube() <br /> PositionEntity cube,0,0,5 <br /> tex=LoadTexture("brick.png")<br /> EntityTexture cube,tex <br /> While Not KeyDown(1) <br /> RenderWorld <br /> Flip <br /> Wend <br /> End <br /> </tt></span></p> Is there a way to set the width - I can't seem to find one. Many thanks. T Hey all. I just recent finished the following site for a client: http://www.stagingupstyle.com/ My client would like me to change the formatting of the text on the "Designer" page to be block text like a news paper. Does anyone know how to do this? Here is an example of block text. http://www.readingonline.org/article...r/image1ri.gif What is the proper use of the ID and CLASS tags. I think I know but I'm not entirely sure. My understanding is that IDs and CLASSes do the same thing. Also, when it comes to the DISPLAY--hmm it's not a selector... modifier?--and its attribute is BLOCK; does that make it so that there's a line break after the </p> like a <br /> does? Thanks in advance for any help. Hey everyone! I am a game developer and some of my games apear in Internet Explorer. The problem is that the players can resize the window if they got IE7 or IE8. On the previous versions this wasn't possible because I blocked it using HTML. How do I block this resizing option (100%..125%...) now? THANKS Hello, I want to block off my website without Uploading a Website closed HTML file. Is there a possible way to do it? If you have no idea what im talking about, please look at Limewire website. It has a thing that pops up and blocks off the site. I want it exactly like that. Thanks in advanced! (and dont judge me, this is my first forum post) Trying to modify a template.. http://www.varaxon.com/ On the right, below the login box are 3 seperate boxes - I've been trying to make these completely clickable - I just can't seem to figure it out. I tried doing unordered lists, etc. Color me stupid - I'm just a lowly PHP Developer with minimal design/html coding experience. -G Hello, I am semi new to HTML and was wondering if there is an easy way to adjust a price.. once a user has selected something from a selection box.. so say they pick an item for 10$ the price field then increases 10$.. same for if they downgrade price decreases. any ideas. Hi. I am currently struggling to find a simple sollution to the following issue. I want to render out a text input box in HTML that will have a block (with borders) for every character. I can think of really tedious solutions that will involve a table with an input tag per cell but this will be nasty if something else is available. The solution is only for IE and cannot involve any ActiveX components due to security issues. So is there any easy way to basically create internal borders in an input or textbox tag that will separate the characters for me? Thanks. Hi, I was wondering if someone could explain block and inline elements. I know they deal with word wrap but, I have read and I am still confused on how you know what is a block element and what is an inline element. Can someone provide some aid? Thanks. I have a Web Page with the following HTML code: <div id= "BlockA" > <div style="position:absolute;left:31.82px;top:79.70px" class="cls_005">Text 1</div> <div style="position:absolute;left:340.70px;top:79.70px" class="cls_005">Text 2</div> <div style="position:absolute;left:31.10px;top:92.90px"> <span class="cls_005">Text 3</span> <span class="cls_002">Text 4</span></div> <div style="position:absolute;left:105.02px;top:92.90px" class="cls_005">Text 5/div> </div> "BlockA" is usually displayed without highlighting. However, under certain circumstances (as controled by my Web App), I would like to highlight (e.g. with backgroundcolor = "yellow") "Block A" when the Web page is displayed. The highlight should not change the classes in the div and span within "BlockA". Can anyone suggest how can I do this? Thanks in advance. sg2000 Hi, In my site: www.theticketsguide.com I am trying to set the width of the text "This is a test. Sample content..." to only span about half the page. This is the code I have so far: <font style="color: rgb(204, 204, 204);" size="6" width="440" ><span style="font-family: Arial,Helvetica,sans-serif;">This is a test. Sample content will go here. Sample content will go here. Sample content will go here.</span></font></h1> The width function isn't working. What am I doing wrong? Thanks, Brandon Hi guys, im new to the forum, but you all seem friendly and helpful, so here goes! I'm doing a part-time Uni course 'Creating Websites using HTML', and my assignment involves building a website... simple as that Anyway, I have a question for you experts!... I'm using various PCs (work, home, uni), and whenever I save the files and email them to the next PC im using, when I view the HTML source (from IE - latest version), the text is automatically displayed in one long block!! This is very frustrating and time consuming as I have to break the text up, exactly as I originally typed it. Is there a way I can prevent this from happening? Thanks in advance for any help, Greg Hi all; I've had this problem with years and have assumed it was a problem with my hosting agent. Let me explain: Despite what I believe is correct code and correct "local" representation on my web-site when testing on my browsers, my uploaded web-site will not display the title of the page. It works when saved and tested locally, but only shows "Mozilla Firefox" when uploaded to my space. I host my site in my generic space allocated with my web account. The same thing happened with my old page, which I built from scratch, My new page is one I downloaded off a template page kindly supplied by Tristar Design. Can a guru go to my site and view source to ensure that it is the hosting agent and not my code? That would be much appreciated: http://www.captainalbion.com Cheers Dan, Australia |