Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Floats problem

  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    81
    Thanks
    45
    Thanked 0 Times in 0 Posts

    Floats problem

    <div id="header"> Website <span id="boldtitle"> Productions</span> </div>
    <div id="logo"> </div>


    #header {font-size:2em;font-family:arial, sans-serif;padding:20px;float:left;}
    #boldtitle{font-weight:bold;}
    #logo{background-image:url(logobmw.png);background-repeat:no-repeat;width:100px;height:100px;float:right;padding:20px;}

    Basically padding only working on left size, neither padding-top works.

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,682
    Thanks
    22
    Thanked 1,828 Times in 1,812 Posts
    They both have padding when I try your code here. Maybe your problem is caused by something you haven't shown us?

    Look at it this way -
    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	margin: 0;
    	font: 100% "Trebuchet MS", Arial, Helvetica, sans-serif;
    	color: #000;
    	background: #fc6;
    }
    #container {
    	width: 800px;
    	margin: 0 auto;
    	background: #999;
    }
    #header {
    	padding: 20px;
    	float: left;
    	font-size: 2em;
    	font-family: arial, sans-serif;
    }
    #boldtitle { font-weight: bold; }
    #logo {
    	height: 100px;
    	width: 100px;
    	padding: 20px;
    	float: right;
    	background: url(logobmw.png) no-repeat;
    }
    </style>
    </head>
    <body>
    <div id="container">
    	<div id="header"> Website <span id="boldtitle"> Productions</span> </div>
    	<div id="logo"> </div>	
    	<!--end container--></div>
    </body>
    </html>
    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

  • Users who have thanked Excavator for this post:

    h123er2 (03-26-2013)

  • #3
    New Coder
    Join Date
    Mar 2013
    Posts
    81
    Thanks
    45
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Excavator View Post
    They both have padding when I try your code here. Maybe your problem is caused by something you haven't shown us?

    Look at it this way -
    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	margin: 0;
    	font: 100% "Trebuchet MS", Arial, Helvetica, sans-serif;
    	color: #000;
    	background: #fc6;
    }
    #container {
    	width: 800px;
    	margin: 0 auto;
    	background: #999;
    }
    #header {
    	padding: 20px;
    	float: left;
    	font-size: 2em;
    	font-family: arial, sans-serif;
    }
    #boldtitle { font-weight: bold; }
    #logo {
    	height: 100px;
    	width: 100px;
    	padding: 20px;
    	float: right;
    	background: url(logobmw.png) no-repeat;
    }
    </style>
    </head>
    <body>
    <div id="container">
    	<div id="header"> Website <span id="boldtitle"> Productions</span> </div>
    	<div id="logo"> </div>	
    	<!--end container--></div>
    </body>
    </html>


    somebody said padding doesnt work when you're using floats, is that true?

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,682
    Thanks
    22
    Thanked 1,828 Times in 1,812 Posts
    Quote Originally Posted by h123er2 View Post
    somebody said padding doesnt work when you're using floats, is that true?
    No. Both padding and margin should work fine. If they don't, something else is causing the problem.
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •