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: CSS Help Please

  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    CSS Help Please

    Hello there,

    Without using CSS in HTML, I was using the code given below within BODY to show following two images:
    1. one in the background
    2. other on the left side


    Code:
    <img src="http://www.urdufans.com/forum/ls/admin.gif" style="border: 0pt none;"> <span style="color: #FF0000; background-image: url('http://www.urdufans.com/forum/bg/admin.gif')"><b>Mujahid Taban</b></span>
    Using this code I was showing both images like

    Now I want to use CSS within HEAD. Please tell me what CSS code I can use for this purpose?

    Regards,
    mujahidtaban

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    # one in the background
    # other on the left side
    Can we have your complete html to see an elaborated picture?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Let me elaborate my question.

    For , I am using following code:
    Code:
    <html>
    
    <head>
    
    </head>
    
    <body>
    <img src="http://www.urdufans.com/forum/ls/admin.gif" style="border: 0pt none;"> <span style="color: #FF0000; background-image: url('http://www.urdufans.com/forum/bg/admin.gif')"><b>Mujahid Taban</b></span>
    </body>
    
    </html>
    Now I want to use an external CSS file in order to reduce my code becasue I have to use "Mujahid Taban" many times in the page. Someone suggested me following CSS and HTML:

    In style.css file:
    Code:
    img{
      border:none;
    }
    		
    #heart{
      color: #FF0000;
      background-image: url('http://www.urdufans.com/forum/bg/admin.gif');		
    }
    In index.html file:
    Code:
    <html>
    
    <head>
    <link rel="stylesheet" href="style.css" type="text/css">
    </head>
    
    <body>
    <img src="http://www.urdufans.com/forum/ls/admin.gif"> <span id="heart"><strong>Mujahid Taban</strong></span>
    </body>
    
    </html>
    That reduced the code a little but I want only following code in HTML:
    Code:
    <span id="heart">Mujahid Taban</span>
    Everything else should too be in external CSS. What CSS code I should use for LEFT SIDE image (heart) and for removing strong.

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello mujahidtaban,
    Since you can't have multiple background images we need to add another containing element of some sort. I just picked h1 because this looks like a heading?
    See if this works for you -
    Code:
    <!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>Untitled Document</title>
    <style type="text/css">
    html, body {
    	margin: 0;
    	background: #FC6;
    	font: 100% Verdana, Geneva, sans-serif;
    }
    #container {
    	width: 800px;
    	margin: 30px auto;
    	background: #999;
    	overflow: auto;
    }
    h1 {
    	padding: 0 0 0 20px;
    	font-size: 1em;
    	color: #f00;
    	background: #fff url(http://www.urdufans.com/forum/ls/admin.gif) no-repeat;
    }
    	#sparkle {background: url(http://www.urdufans.com/forum/bg/admin.gif);}
    </style>
    </head>
    <body>
        <div id="container">
        	<h1><span id="sparkle">Mujahid Taban</span></h1>
        <!--end container--></div>
    </body>
    </html>
    That's a little confusing, naming both images admin.gif...
    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:

    mujahidtaban (12-19-2010)


  •  

    Posting Permissions

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