SitePoint Sponsor

User Tag List

Results 1 to 15 of 15

Thread: Help with CSS

  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with CSS

    Hi guys,

    I'm working on a new site, and I'm having a bit of a hard time getting some CSS to work out nicely. Basically, I'm trying to make a window that I will have my content in (impersonating a mac window -- fitting for a mac fan site [i'm not trying any weird phishing attack ]). For the top of the window, I have three images: the close buttons, a small cross-section thats repeated, and a right-hand corner.

    I'm having a hard time getting the top div to spread the same width as the content div. The way I currently have it doesn't allow for the browser to be very narrow.

    My second problem is getting to top div to go directly on top of the content div.

    Here is a link to the html page:
    http://www.macintoshclub.com/newSite/index.htm

    And the CSS:
    http://www.macintoshclub.com/newSite/default.css


    Here is the important HTML:
    <div class="window">
    <div class="top">
    <div class="leftCorner">&nbsp;</div>
    <div class="center">&nbsp;</div>
    <div class="rightCorner">&nbsp;</div>
    </div>
    <div class="bottom">
    Content with divs
    </div>
    </div>


    And the CSS:
    div.window{
    width:75%;

    }

    div.top{
    height:20px;
    width:100%;

    }

    div.leftCorner{
    background: url('window/leftTopCorner.gif') 0 0;
    background-repeat: no-repeat;
    width: 55px;
    float:left;

    }

    div.rightCorner{
    background: url('window/rightTopCorner.gif') 100% 0;
    background-repeat: no-repeat;
    width:15px;
    float:left;

    }

    div.center
    {
    background: url('window/centerTop.gif') 0 0;
    background-repeat: repeat-x;
    vertical-align: top;
    float: left;
    width: 91%;
    }

    div.bottom{
    background-color:#ffffff;
    clear:left;
    width:100%;

    }



    I'd appreciate as much help as I can get. Thanks!

  2. #2
    padawan silver trophy
    SitePoint Award Recipient markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,014
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Hello, and Welcome to Sitepoint

    I would have something like this:

    Code:
    <div class="window">
      <ul class="nav">
        <li class="close"><a title="close" href="#">X</a></li>
        <li class="min"><a title="minimize" href="#">-</a></li>
        <li class="max"><a title="maximize" href="#">+</a></li>
      </ul>
      <div class="content">
        <p>Some content goes here...</p>
      </div>
    </div>
    That's the semantic elements I would use, then you give the three buttons heights/width's / background image and you could use the text-indent: -9999px; method of removing the text from element so it looks like the image.

    You may need a extra div around the nav list if you wanted to make the window of variable width.

    I hope it helps

    I'm working on the CSS now.. as I imagine that my above description could possible be of no help

  3. #3
    SitePoint Wizard bronze trophy bigalreturns's Avatar
    Join Date
    Mar 2006
    Location
    The Wirral, England
    Posts
    1,293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not enough of a CSS whiz to help much with this one, but if you play with resizing the window (FF2.0), then there is a point where the 2 are the same width - when the top right corner image is knocked down below the "status bar" type bit. Here's the shot:
    "The proper function of man is to live - not to exist."
    Get a Free TomTom


  4. #4
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bigalreturns:

    yup, you are exactly right. That was one of my questions, that I suppose I didn't word properly. I need to fix that and would like some help. I'm trying out markbrown4s idea now.

  5. #5
    padawan silver trophy
    SitePoint Award Recipient markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,014
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    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=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    /* reset all padding/margin on all elements */
    * {
    	margin: 0;
    	padding: 0;
    }
    .window{
    	width:75&#37;;
    	background: #FFF;
    }
    
    .nav{
    	width:100%;
    	background: #D2D4D1 url(http://www.macintoshclub.com/newSite/window/centerTop.gif) repeat-x top left;
    	overflow: auto;
    }
    .nav ul {
    	width:100%;
    	list-style: none;
    	background: transparent url(http://www.macintoshclub.com/newSite/window/rightTopCorner.gif) no-repeat top right;
    	overflow: auto;
    }
    .nav li {
    	float: left;
    }
    .nav li a {
    	float: left;
    	height:20px;
    	width: 20px;
    	text-indent: -9999px;
    	background: #D2D4D1 url(http://www.macintoshclub.com/newSite/window/leftTopCorner.gif) 0 0;
    }
    .nav li.min a {
    	background-position: -20px 0
    }
    .nav li.max a {
    	background-position: -40px 0;
    	width: 15px;
    }
    .content {
    	border: 1px solid #000;
    }
    </style>
    </head>
    
    <body>
    <div class="window">
      <div class="nav">
    	  <ul>
    		<li class="close"><a title="close" href="#">X</a></li>
    		<li class="min"><a title="minimize" href="#">-</a></li>
    		<li class="max"><a title="maximize" href="#">+</a></li>
    	  </ul>
      </div>
      <div class="content">
        <p>Some content goes here...</p>
      </div>
    </div>
    </body>
    </html>
    Now you get the cool little tooltips

  6. #6
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yay, it works!!! Thank you.

  7. #7
    padawan silver trophy
    SitePoint Award Recipient markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,014
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    just for fun
    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=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    /* reset all padding/margin on all elements */
    * {
    	margin: 0;
    	padding: 0;
    }
    body  {
    	background: #F6F6F6;
    	padding: 20px;
    }
    #window{
    	width:75&#37;;
    	background: #F1F1F1;
    }
    
    .nav{
    	width:100%;
    	background: #F1F1F1 url(http://www.macintoshclub.com/newSite/window/centerTop.gif) repeat-x top left;
    	overflow: auto;
    }
    .nav ul {
    	width:100%;
    	list-style: none;
    	background: transparent url(http://www.macintoshclub.com/newSite/window/rightTopCorner.gif) no-repeat top right;
    	overflow: auto;
    }
    .nav li {
    	float: left;
    }
    .nav li a {
    	float: left;
    	height:20px;
    	width: 20px;
    	text-indent: -9999px;
    	background: #F1F1F1 url(http://www.macintoshclub.com/newSite/window/leftTopCorner.gif) 0 0;
    }
    .nav li.min a {
    	background-position: -20px 0
    }
    .nav li.max a {
    	background-position: -40px 0;
    	width: 15px;
    }
    .content {
    	border: 1px solid #AAA;
    	border-top: 1px solid #CCC;
    	height:200px;
    	padding: 10px;
    	background: #FFF
    }
    </style>
    <script type="text/javascript" language="javascript">
    <!--
    
    function maximiseWindow() {
    	document.getElementById('window').style.width = "100%";
    }
    
    function minimiseWindow() {
    	document.getElementById('window').style.width = "70%";
    }
    
    function closeWindow() {
    	if (confirm("Are you sure you want to close the window?")) {
    		document.getElementById('window').style.display = "none";
    	}
    }
    
    //-->
    </script>
    </head>
    
    <body>
    <div id="window">
      <div class="nav">
    	  <ul>
    		<li class="close"><a onclick="closeWindow()" title="close" href="#">X</a></li>
    		<li class="min"><a onclick="minimiseWindow()" title="minimise" href="#">-</a></li>
    		<li class="max"><a onclick="maximiseWindow()" title="maximise" href="#">+</a></li>
    	  </ul>
      </div>
      <div class="content">
        <p>Some content goes here...</p>
      </div>
    </div>
    </body>
    </html>
    Edit:
    ^^ Updated CSS to make it look more mac
    The only thing I would change is to have the corner images not use a transparent background for smoother looking edges. The right corner requires it because it is sitting on top of another background.

  8. #8
    SitePoint Wizard bronze trophy bigalreturns's Avatar
    Join Date
    Mar 2006
    Location
    The Wirral, England
    Posts
    1,293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK well I was beaten to it...and I didn't even bother separating the 3 buttons out, but here you go anyway!

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Macintosh Club</title>
    <style type="text/css">
    * {
    margin:0;
    padding:0;
    }
    .window {
    background: url('leftTopCorner.gif') no-repeat top left;
    width:75&#37;;
    height:200px;
    margin:20px;
    }
    .nav {
    list-style:none;
    background: url('rightTopCorner.gif') no-repeat top right;
    width:100%;
    }
    .nav li {
    display:inline;
    margin-left:-9999px;
    }
    .bar {
    background: url('centerTop.gif') repeat-x top left;
    margin-left:55px;
    }
    </style>
    </head>
    
    <body>
    <div class="window">
      <div class="bar">
        <ul class="nav">
          <li class="close"><a title="close" href="#">X</a></li>
          <li class="min"><a title="minimize" href="#">_</a></li>
          <li class="max"><a title="maximize" href="#">+</a></li>
        </ul>
      </div>
      <div class="content">
        <p>Some content goes here...</p>
      </div>
    </div>
    </body>
    </html>
    "The proper function of man is to live - not to exist."
    Get a Free TomTom


  9. #9
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't want to be too picky or anything, but the center image runs all the way to the left and right which makes the corner of the window look a bit odd. Anyway to have this not happen? I'm trying to change the margin, but its not working.

  10. #10
    padawan silver trophy
    SitePoint Award Recipient markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,014
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Change the images - don't use transparent backgrounds see comment above - This one's just Awesome
    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=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    /* reset all padding/margin on all elements */
    * {
    	margin: 0;
    	padding: 0;
    }
    body  {
    	font-family: "Lucida Grande",Geneva,Arial,Verdana,sans-serif;
    	background: #F1F1F1;
    	padding: 20px;
    	font-size: 100&#37;;
    }
    h1, h2, p {
    	color: #333;
    	font-size: 80%;
    	margin-bottom: .8em;
    	line-height: 1.2em;
    }
    #window{
    	width:75%;
    	background: #F1F1F1;
    }
    
    .nav{
    	width:100%;
    	background: #F1F1F1 url(http://www.macintoshclub.com/newSite/window/centerTop.gif) repeat-x top left;
    	overflow: auto;
    }
    .nav ul {
    	width:100%;
    	list-style: none;
    	background: transparent url(http://www.macintoshclub.com/newSite/window/rightTopCorner.gif) no-repeat top right;
    	overflow: auto;
    }
    .nav li {
    	float: left;
    }
    .nav li a {
    	float: left;
    	height:20px;
    	width: 20px;
    	text-indent: -9999px;
    	background: #F1F1F1 url(http://www.macintoshclub.com/newSite/window/leftTopCorner.gif) 0 0;
    }
    .nav li.min a {
    	background-position: -20px 0
    }
    .nav li.max a {
    	background-position: -40px 0;
    	width: 15px;
    }
    #content {
    	border: 1px solid #AAA;
    	border-top: 1px solid #CCC;
    	height:200px;
    	padding: 10px 30px 10px 10px;
    	background: #FFF;
    	overflow: auto;
            position: relative; /* Fixes IE dissapearing text bug */
    }
    </style>
    <script type="text/javascript" language="javascript">
    <!--
    
    function maximiseWindow() {
    	var macwindow = document.getElementById('window');
    	var maccontent = document.getElementById('content');
    	macwindow.style.width = "100%";
    	maccontent.style.overflow = "visible";
    	maccontent.style.height = "auto";
    	maccontent.style.minHeight = "300px";
    	
    }
    
    function minimiseWindow() {
    	var macwindow = document.getElementById('window');
    	var maccontent = document.getElementById('content');
    	macwindow.style.width = "70%";
    	maccontent.style.overflow = "auto";
    	maccontent.style.height = "200px";
    	maccontent.style.minHeight = "";
    }
    
    function closeWindow() {
    	if (confirm("Are you sure you want to close the window?")) {
    		document.getElementById('window').style.display = "none";
    	}
    }
    
    //-->
    </script>
    </head>
    
    <body>
    <div id="window">
      <div class="nav">
    	  <ul>
    		<li class="close"><a onclick="closeWindow()" title="close" href="#">X</a></li>
    		<li class="min"><a onclick="minimiseWindow()" title="minimise" href="#">-</a></li>
    		<li class="max"><a onclick="maximiseWindow()" title="maximise" href="#">+</a></li>
    	  </ul>
      </div>
      <div id="content">
        <h1>Content </h1>
        <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam ac  neque. Morbi ac ante ut augue rhoncus facilisis. In rhoncus justo.  Donec accumsan. Quisque tempor velit vitae enim. Morbi a odio. Aliquam  erat volutpat. Suspendisse potenti. Nunc imperdiet ullamcorper eros. Ut  porta arcu id turpis. Donec iaculis. Fusce ac quam. Vivamus fermentum  tincidunt lacus. Ut vestibulum velit sit amet justo ultrices congue.  Aliquam congue sollicitudin odio. </p>
        <p>Donec in risus eu magna scelerisque bibendum. Nam id erat eget eros  porttitor tempus. Nam adipiscing lobortis velit. Donec aliquet  scelerisque elit. Quisque porttitor bibendum nulla. Proin gravida,  felis et tempor mattis, metus mi fermentum odio, a venenatis tortor  elit vitae leo. Etiam id libero quis elit volutpat scelerisque. Nunc  nonummy. Etiam sed lacus. Cras elementum. Cum sociis natoque penatibus  et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque  feugiat orci id nulla. Pellentesque habitant morbi tristique senectus  et netus et malesuada fames ac turpis egestas. Vivamus eros tortor,  ullamcorper sed, consequat quis, dapibus quis, neque. </p>
      </div>
    </div>
    </body>
    </html>

  11. #11
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, just have my images not be transparent, and that should fix it?

  12. #12
    padawan silver trophy
    SitePoint Award Recipient markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,014
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    yep.

  13. #13
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok. Last question [hopefully] about these darn windows. How would you suggest getting a title on them (so it goes over the window part)? Z-level? Or is there a better way?

  14. #14
    padawan silver trophy
    SitePoint Award Recipient markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,014
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I've put up an example:
    http://www.yellowshoe.com.au/mac_sty...ac_window.html

    Avoid absolute positioning wherever you can, there's nearly always a better alternative.

  15. #15
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much. You've been really helpful!

Bookmarks

Posting Permissions

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