CSS - Help In Css, How To Setup Auto Width And Height
Hi to all, and thanks a million in advance for help.
I have developed a simple online cms and everything is setup correctly but i am stuck at one place. I am unable to make width to 100% when b div is empty i mean a div = 50% width, b div = 50% width, how set it up that when a div is empty then b div goes to 100%width and when b div is empty then a div is 100% width. i hope got my question. because currently i have set in this way. wrapper div = 980px width, a div = 50% width, b div = 50% width, wrapper div end so when a div is empty then b div is still present and that area is empty it destroy the whole look. thanks arsslan Similar TutorialsHi Guys, Consider the following box: PHP Code: <div style=border: 1mm black Solid; width: 148mm; height: 98mm;'> </div> 148mm + 1mm + 1mm = width of 150mm 98mm + 1mm + 1mm = width of 100mm Now why does neither firefox or ie manage to get it? Firefox is about 2mm out and ie is about 3mm out? Any ideas or is it some quirk? Charlie I am building a custom form control that behaves more or less like a <select> menu. For the dropdown portion of the menu, I need to set a max-height. If the dropdown contains enough options to go beyond the max-height a vertical scrollbar should appear. 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>Custom Auto-Complete</title> <script type="text/javascript"> <!-- function initPage() { } --> </script> <style type="text/css"> <!-- body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 76%; } input { width: 200px; background: #f4f4f4; border: 1px solid #999; font-size: .9em; /* */ } .clearfix { display: inline-block; } .clearfix:after { content:"."; display:block; height:0; clear:both; visibility:hidden; } .cAutoCompleteCtl { position: relative; /* border: 3px solid red; */ } .cAutoCompleteCtl input { margin: 0 5px 0 0; display: block; float: left; } .cAutoCompleteCtl a.dwnarrow { width: 15px; height: 15px; border: 1px solid #999; background: url(images/downarrow.gif) no-repeat; background-position: center center; background-color: #efefef; float: left; display: block; font-size: 1px; text-decoration: none; } .cAutoCompleteCtl .acCtlDropdwn { position: absolute; top: 20px; left: 0px; z-index: 100; visibility: visible; min-width: 300px; max-width: 600px; height: auto; max-height: 200px; background: #fff; padding: 5px; border: 1px solid #999; overflow: auto; /* width: 400px; */ } * html .cAutoCompleteCtl .acCtlDropdwn { width: expression( this.scrollWidth < 330 ? "300px" : ( this.scrollWidth > 620 ? "600px" : "auto" ) ); height: expression( this.scrollHeight < 20 ? "200px" : ( this.scrollHeight > 301 ? "300px" : "auto" ) ); } .cAutoCompleteCtl .acCtlDropdwn a { white-space: nowrap; display: block; text-decoration: none; padding: 2px 5px; color: #000; border: 1px solid #fff; } .cAutoCompleteCtl .acCtlDropdwn a.lastOption { } .cAutoCompleteCtl .acCtlDropdwn a:hover { background: #f5f5f5; border: 1px solid #b3b3b3; } --> </style> </head> <body onload="initPage();"> <div class="cAutoCompleteCtl clearfix"> <input type="text" /><a href="" class="dwnarrow"> </a> <div class="acCtlDropdwn"> <!--<a href="#">options here options here options here options here options here options here options here options here options here options here options here</a>--> <a href="#">options here</a> <a href="">Boulder Logic</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> <a href="">A Rference With A Different Name</a> </div> </div> </body> </html> I'm seeing some unexpected behaviour ihn Firefox. When the page is loaded for the 1st time, the height of the dropdown portion of the menu is only large enough to see 1 option and no scrollbars are displayed. If I hit refresh (without holding the Shift key), the menu's height goes to its max-height and displays as expected. The only property I could find that has any effect on this behaviour is overflow. If I remove it all together or set it to scroll, it displays at the correct height. Unfortunately, neither of these are an option since they will not produce the desired scrolling behaviour. Can anyone see where I'm going wrong? Hi, I have hit the "wall" in my knowledge of CSS while trying to implement a "flex-width-equal-height-sidebar-layout" style of layout as a skin/theme for a message board system and need some help. My trouble occurs when a direct link to the post is used (instead of following the menu navigation system) where the top menu information/links area (the area between the banner and the post) is chopped off... The relevant portion of the CSS seems to be the .col_wrap {margin-top: 10px; border: 0; overflow: hidden; float: left; width: 100%; position: relative; z-index: 10; clear: both;} portion of my CSS because if I take out the overflow:hidden declaration then the menu portion of the skin/theme/layout shows correctly but the sidebar the shows the part which should be hidden at the bottom and the footer completely vanishes from view! My apologies but this is the best I can do without having the ability to post pics or urls which could better explain what is wrong and frankly speaking I don't know how anyone here can help given my inability to show the problem but hopefully someone knows or has run into this problem before or can offer some resources that may be of assistance.... Afternoon Folks! Have a seemingly simple problem here but I can't seem to figure it out. I have a Horizontal drop-down CSS menu. It's working really well in FF but our fav friend IE is reading it differently. I'm using a list for my nav, with an auto width and 15px padding left/right. But in IE it registers my width as 100% so my horizontal menu turns into a vertical menu. edit:: using IE6 as my base test simply because IE7 isn't an "Approved Software" for work yet.. haha! I'm about to head out to lunch in a few and wanted to see if some CSS wiz's could slap me and help me find the best solution for my needs. I'm sure it's simple and I just keep scimmin right over it. So I uploaded what I have for it. It can be seen here This is the style which defines my width: css Code: Original - css Code #pmenu a, #pmenu a:visited { display:block; padding: 0 15px; width: auto; font-size:11px; color:#fff; height:25px; line-height:24px; text-decoration:none; border-right: 1px dotted #fff; } #pmenu a, #pmenu a:visited { Of course, any and all help is appreciated! TYTY! TIA! Lates! It always amazes me how Microsoft can mess something up that was working before. Take the following example, a table cell set to a specific width, containing a div, width set to 100% of its containing block element (the table cell). Overflow:auto is applied to the div and content is placed in the cell that cannot be wrapped. See the code that follows: html4strict Code: Original - html4strict Code <table width="200px" cellpadding="0" cellspacing="0" border="0"> <tr> <td style="width: 200px;"> <div style="width: 100%; overflow: auto;"> <p style="white-space: nowrap;">Content that should not be wrapped.</p> </div> </td> </tr> </table>
One would expect to have the table cell display with a width of 200 pixels and scrollbars will be displayed for the un-wrappable content. IE7 does not do that. It widens the cells width to accommodate the content. FF follows this perfectly. To fix this, one has to set the div to the same width as the table cell, like so: html4strict Code: Original - html4strict Code <table width="200px" cellpadding="0" cellspacing="0" border="0"> <tr> <td style="width: 200px;"> <div style="width: 200px; overflow: auto;"> <p style="white-space: nowrap;">Content that should not be wrapped.</p> </div> </td> </tr> </table>
Only then, IE7 will correctly display it. Just something to keep in mind when working with percentage widths. hello everyone, i am using css based menu . requirement is that, menu should adjust its width automatically based on the text length. Here is my css : = css Code: Original - css Code li ul li { background: #000; color: #fff; padding-top: 4px; border-bottom: 1px solid #fff; letter-spacing:1px; text-transform: capitalize; text-shadow: 2px 2px 2px #22222; width: 250px; margin:0px auto; height: 18px; font-size: 11px; font-weight: normal; text-align:left; filter: alpha(opacity=80); opacity: 0.8; -moz-opacity: 0.8; }
you just see the attachment, you would realise that , the text is cropping & not displayed. Also , can any one suggest , what can I do to make this CSS to cause make it attractive.? Currently on my site I have articles with images, and the images have a quote underthem... unforutunatly, i have to manually set the width of these boxes to the width of the image that accompanies them.... here is a sample... CSS: Code: .imageinsert { margin:5px; } #image01 {width:225px} .imagequote { color:#FFF; font-weight:bold; font-family:Arial, Helvetica, sans-serif; font-size:11px; text-align:center; } XHTML: Code: <div class="imageinsert" id="image01"> <img src="/pic/feud093.jpg" alt="" /> <div class="imagequote">In yet another unfair battle, Maki must defend herself against Guy and Guile!</div> </div> I would love to have just one code for the imageinsert tag that would just autoresize based on how wide the image was. Hi All, I have CSS-sheet= .thumbs { border: 2px solid #524b2f; position: static; height: 80px; width: auto; } body { background-color: #f5f0ec; font-family: Verdana, Arial, Helvetica, sans-serif; scrollbar-face-color : #f5f0ec; scrollbar-highlight-color : #aca899; scrollbar-3dlight-color : #f5f0ec; scrollbar-shadow-color : #aca899; scrollbar-darkshadow-color :#f5f0ec; scrollbar-track-color : #f5f0ec; scrollbar-arrow-color : #524b2f; } The thumbs part resizes some pictures to a fixed height of =80px and calculates the width so everyting is resized correctly. But IE6 gives problems with the width=auto , some times it's sets the widt correctly other times it doesn't. In other brouwsers its fine. Any suggestions on fixing this in IE6? here's the page link : http://www.sleuyter.be/04/lay04-1.htm thx, ROY I'm pretty new to this so I'm not 100% sure what I'm doing yet. However, I've created a test page to show you guys the rendering issue that I'm experiencing. The page renders how I want it to in Firefox, Flock and Chrome. It renders incorrectly in IE8 (which is a required browser that this needs to be supported in). Here is a link to the test page cm-rosestate.mine.nu/test.aspx and the css is /MyStyle.css My suspicion is that it's a problem with the css and/or the doctype. However, I just don't know enough about this to know how to troubleshoot it. Any help or insight will be appreciated. I'm designing a page he (URL address blocked: See forum rules) I'm confused on how to make the top bar image span the width of each side and still be in synch with the center background image. I've done this with tables on the old version of the site (here ), but is it possible with CSS? Here's the code for the bars currently: .BGLEFTTOP{ position:absolute; left:0%; top:0px; height:88px; width:50%; margin-left:-456; background:url((URL address blocked: See forum rules)) repeat-x; background-position: right top; z-index:1;} .BGRIGHTTOP{ position:absolute; right:0%; top:0px; height:88px; width:50%; background:url((URL address blocked: See forum rules)) repeat-x; background-position: left top; z-index:1;} Hi guys, Before I go on, here's the page I'm referring to: http://student-consolidation-loans.co.uk/newsite3/ In IE 6 on the PC the layout is how I want it, however, skip over to the mac and it doesn't look correct in any browser (safari, IE, firefox...) The problem is I've given one of the DIVs (the one that contains the white and black diagonally striped background) an auto height so it stretches to fit all the content, but while IE 6 is picking up on this none of the mac browsers are. Is there a workaround? thanks! So, I have a div that is acting as a container. I contains a background image and colour that goes beyond the image should the image not be big enough for certain resolutions. Anyways inside this div container are 2 more divs, one with a set height that holds images, and another one below the first one that holds text. Now this text changes on a regular basis, but I don't really want to have to adjust the height of the container div everytime I add more text or take away text, I want it to automatically adjust the height as it needs to. I tried setting the height property to auto, but that didn't do anything. Just wondering if someone knows a way to do this? Hi all, I have come back to designing websites after a long time and I am having problems making the height auto work in firefox. The css code: Code: div.t2_container{ width:679px; height:auto; text-align:left; padding-top:10px; padding-bottom:10px; background:#e7e7e9; } div.t2_col1{ float: left; width:470px; height:auto; display: inline; clear:both; background:#FFFFCC; } div.t2_col2{ float: right; width:199px; height:auto; display: inline; background:#CCFFFF; } and the html: Code: <body> <div class="t2_container"> <div class="t2_col1"><p>text text</p><p>text text</p><p>text text</p></div> <div class="t2_col2"><p>text text</p><p>text text</p><p>text text</p><p>text text</p></div> </div> </body> IE recognizes the height = auto on the container div and resizes so that the inner divs are contained within the grey bounding box of the container. However firefox does not recognize this and the 2 inner divs fall outside the container which is left hanging thin at the top. Does anyone know a fix for this pls? Thanx Hello! I'm hoping you guys could help me with a small problem.. I'm trying to get my images to keep their aspect ratio with this CSS, #photo-inner img { margin: 0 0 10px; padding: 0 0 10px; max-width: 718px; width: expression(this.width > 718 ? 718: true); height: auto; } Works perfectly in Firefox, Safari.. But IE don't want to play along. Any tips? // T Let me start by saying I'm new to CSS and web developement in general. So I'm probably missing something simple. I have an ASP page that has a treeview along the left, and a tab control to the right of it. I put everything in div's, and floated left the treeview and tab div's. I put a div around it all to have a border. I set that div to be height:auto (or 100%), and it doesn't expand at all. I can give it a true height, but that's not really what I want. Also, it I resize my page really small (manually), the tab div drops below the tree div. Here is the code. Can anyone point me in the right direction to accomplish what I'm trying to do? Thanks! Code: <%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/App/Master/AmcMaster.Master" CodeBehind="CoreWorkload.aspx.vb" Inherits="Core.UI.CoreWorkload" title="Core Workload" %> <%@ MasterType VirtualPath="~/App/Master/AmcMaster.Master" %> <%@ Register tagprefix="controls" src="~/Controls/CoreWorkloadTv.ascx" tagname="CoreWorkloadTree" %> <asp:Content ID="Content1" ContentPlaceHolderID="AuthContent" runat="server"> <asp:UpdatePanel ID="CoreWorkloadUpdatePanel" UpdateMode="Conditional" runat="server"> <ContentTemplate> <div id="coreWorkloadDiv" style="border-style: solid; border-width: thin; height: auto; padding-top: 5px;"> <div id="treeDiv" style="width:150px; height: 100%; overflow:auto; float:left;" > <controls:CoreWorkloadTree id="wbsTree" runat="server"></controls:CoreWorkloadTree> </div> <div id="tabDiv" style="padding: 10px; float: left; width: 80%; height: 100%; "> <ajaxtoolkit:TabContainer runat="server" ID="Tabs" Height="600px" Width="100%" > <ajaxToolkit:TabPanel runat="Server" ID="SummaryPanel" HeaderText="Summary"> <ContentTemplate> <br />WBS Summary data goes here... </ContentTemplate> </ajaxToolkit:TabPanel> <ajaxToolkit:TabPanel runat="Server" ID="DetailPanel" HeaderText="Detail"> <ContentTemplate> <br />WBS Detail data goes here... </ContentTemplate> </ajaxToolkit:TabPanel> </ajaxtoolkit:TabContainer> </div> </div> </ContentTemplate> </asp:UpdatePanel> </asp:Content> Hi Guys I am currently trying to make a website, the problem is that its not quite working..... I have a main div that holds everything inside it but when i set its height to auto its not staying the correct length. Basically i want this main div to stretch out longer every time new content is added (dynamically). Why is it not staying as long as the content thats contained within it? Anyone know why this is happening and how i can fix it ? Help?! Code: #main { height: auto; width:868px; margin-left:15px; margin-top:15px; background-color:#FFFFFF; margin-bottom:3px; } Thanks I wish to set a container to have auto height... meaning the height of the container is defined by it's contents. I have had this working in many other designs... but this one baffles me. (Problem is only in good browsers mozila/firebird) Here it is with the height of #main @ auto (attached) Here it is with the height of #main @ 600px (attached) Here is the HTML code: Code: <!-- Code --> <!-- Document --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Ben Gunn</title> <link rel="stylesheet" href="index.css" /> </head> <body> <div id="main"> <img src="images/default_header.gif" id="header" height="120" width="749"/> <div id="content"> <div class="left"> <ul id="nav"> <li><a href="#">News</a></li> <li><a href="#">Music</a></li> <li><a href="#">Media</a></li> <li><a href="#">Bio</a></li> <li><a href="#">Contact</a></li> </ul> </div> <div class="right"> </div> </div> </div> <br /><br /> </body> </html> And here is the code for the CSS: Code: body { margin: 0; padding: 0; background-color: #666666; } #header{ margin-left: 2px; } #main { position: relative; width: 756px; height: 600px; left: 50%; margin-left: -355px; margin-top: 20px; background-image:url("images/background-bezel.gif"); background-repeat: repeat-y; padding: 0px; padding-bottom: 20px; /*border: black 1px solid;*/ } #content{ padding: 10px; } .left{ float: left; width: 30%; } .right{ float: right; width: 60%; } #nav{ list-style: none; margin: 0; padding: 0; border: none; padding-left: 10px; font: 10pt Verdana, Geneva, Arial, Helvetica, sans-serif; color: white; font-weight: lighter; } #nav li { background-color: #8B0000; border-bottom: 1px solid #CCCCCC; margin: 0; padding: 1px 0 2px 0; } #nav li a { display: block; text-decoration: none; width: 100%; color: white; padding-left: 5px; } html>body #nav li a { width: auto; } #nav li a:hover { background-color: #191970; color: #fff; } Please notify me of the moronic mistakes I am making... thanks. Hello, I've got 3 questions on my mind right now and I can't find answers through the searches. All of them out of curiosity as I try to learn CSS. First, why can't I get my containers height to automatically adjust to the content? Code: #container { position: relative; width: 665px; margin: 0 auto 0 auto; background: #FFFFFF; border: 1px solid #505050; } #buttons { position: absolute; top: 0px; left: 0px; height: 300px; width: 100px; background: #CCCCCC; } // HTML <div id='container'> <div id='buttons'> buttons </div> </div> Second question, what is with the :after I see in CSS examples. I can't get a search on it, so I can't figure out what it is for. I usually see it in a context like (.container:after). Third question, what is with the trailing slash I see before a tag is closed. I think it has something to do with HTML Strict or something. I usually see it in a context like (<tag></tag \>) thanks for the help webg I am trying to layout some content into rows using DIVs. It works fine until I get to the row of 'cells'. If I don't set the height of the container div ("transaction"), it doesn't show the white background. If I make the background of the inner DIVs white, it looks blocky (not solid white bg). I tried float options but that didn't seem to help. Any thoughts? Code: <style type="text/css"> <!-- @charset "utf-8"; body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; font-family: Geneva, Arial, Helvetica, sans-serif; } #contents { position:relative; margin:0 auto; width:700px; text-align:left; } #contents .payPeriod { padding: 8px; background-color:#E8EAFF; margin: 8px; } #contents .dateBlock { font-size: 70%; background-color:#E0E0E0; margin-right: -8px; margin-left: -8px; padding-top: 0; padding-right: 8px; padding-bottom: 0; padding-left: 8px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999; } #contents .transaction { font-size: 160%; background-color:#FFFFFF; margin-right: -8px; margin-left: -8px; padding-top: 0; padding-right: 8px; padding-bottom: 0; padding-left: 8px; float: none; clear: both; height: 80px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: #84C0FD; border-right-color: #84C0FD; border-bottom-color: #84C0FD; border-left-color: #84C0FD; } #contents .details { width: 70%; float: left; } #contents .amount { font-size: 120%; float: left; width: 20%; display: inline; text-align: right; } #contents .posted { float: right; width: 7%; display: inline; text-align: right; } #contents .group { font-size: 150%; float: left; display: inline; } #contents .description { font-size: 70%; float: left; display: inline; clear: both; } #contents .dateTotal { font-size: 130%; text-align: right; } #contents .credittxt { color:#339900; } #contents .dateTotalAmntCredit { font-size: 130%; color:#339900; } #contents .dateTotalAmntDebit { font-size: 130%; color:#990000; } --> </style> <div id="contents"> <div class="payPeriod">pay period: 2008-06-14 <div class="dateBlock">2008-06-14 <div class="transaction"> <div class="details"> <span class="group">merchant </span> <span class="description">merchant </span> </div> <div class="amount"> <span class="credittxt">2424.42</span> </div> <div class="posted">1</div> </div> <div class="transaction"> <div class="details"> <span class="group">test bill </span> <span class="description">test bill </span> </div> <div class="amount"> -20.00 </div> <div class="posted">1</div> </div> <div class="dateTotal">balance <span class="dateTotalAmntCredit">2404.42</span></div> </div> </div> </div> I have a wrapper div 700px wide that is currently set to the following: Code: div.wrapper { width: 700px; height: auto; background-image: url(../local/images/content.gif); background-repeat: repeat; background-attachment: scroll; background-position: top left; text-align: left; padding: 0.05in; position: absolute; left: 50%; margin-left: -350px; border: 2px #000000 ridge; } It renders fine in IE, FF, and Opera. Since the height of the content varies, I am trying to accomplish a minimal fixed height of 700px OR larger if the content is longer than 700 px. Any ideas? |