CSS - Border Properties
I noticed that if you place a border around an object with all sides having different colors, that a diagonal appears in each corner where the two colors meet.
Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>My site</title> <style type="text/css"> #my_id { width: 100px; height: 100px; border-top: 10px solid red; border-bottom: 10px solid green; border-left: 10px solid blue; border-right: 10px solid black; </style> </head> <body> <div id="my_id"> </div> </body> </html> Is there anyway to override this so that for example the bottom border extends from left to right edge at a height of 10px (using the above example) instead of gradually decreasing the height as it nears the edge? Edited to add: I know that I could achieve this effect by nesting divs but I was curious as if there was a simpler solution. Similar TutorialsI am having two problems with my tables right now: Within the style sheet, I have the following: table { border: thin #0000CC; } If I am not mistaken, this should make all tables that have a border of 1 or greater to automatically be thin and blue. This is not working... Why not? D I am creating a standalone (included with <script src>) script to display a slideshow of images, and need the images' container DIV to resize to the height and width of the largest image, PLUS the border width. I can get the height easily enough, but the border is giving me problems. The code I'm using now is: Code: function getcss(myclass,element) { var CSSRules; if (document.all) { CSSRules = 'rules'; } else if (document.getElementById) { CSSRules = 'cssRules'; } for (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) { alert ('.' + document.styleSheets[0][CSSRules][i].style['border'] + '.'); if (document.styleSheets[0][CSSRules][i].selectorText == myclass) { return document.styleSheets[0][CSSRules][i].style[element] } } } function InitializeImageRoller() { for (var q = 0; q < Files.length-1; q++) { var hidden = eval('hiddenpicture' + q); if (MaxW < hidden.width) { MaxW = hidden.width } if (MaxH < hidden.height) { MaxH = hidden.height } Container.style.height = MaxH; Container.style.width = MaxW + getcss('Container','borderWidth'); hidden.style.display = "none"; } } right now I'm testing, and in the first function, I have a line " alert ('.' + document.styleSheets[0][CSSRules][i].style['border'] + '.');". This works fine, but returns ALL the properties of the border. I need it to only give me the width. What should the ['border'] be changed to to accomplish this? Hi. Have created some simple tabs using table cells. Active tab should have bottom-border color equal to page background-color. Non-active tabs should have bottom-border=black. Works fine in IE, but does not work very well in Firefox. If I remove the border-collapse:collapse on the table, then firefox also work... but I would like to be able to keep the 1px border between each table cell. So is there a way to make this work in both IE and Firefox... and hopefully most other browsers... See code below: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <style type="text/css"> a.menu_top:link {color: #000000; text-decoration: none;} a.menu_top:visited {color: #000000; text-decoration: none;} a.menu_top:hover {color: #000000; text-decoration: none;} a.menu_top:active {color: #000000; text-decoration: none;} td.menu_top_passive { background-color: #777; border-left: 1px #000000 solid; border-right: 1px #000000 solid; border-top: 1px #000000 solid; border-bottom: 1px #000000 solid; text-align: center; cursor:pointer; font-weight: bold; padding: 5px 20px 5px 20px; margin: 0; } td.menu_top_active { background-color: #bbb; border-left: 1px #000000 solid; border-right: 1px #000000 solid; border-top: 1px #000000 solid; border-bottom: 1px #bbb solid; text-align: center; cursor:pointer; font-weight: bold; padding: 5px 20px 5px 20px; margin: 0; } </style> <script language="JavaScript"> function change(id, url) { for (i=1; i<6; i++){ eval("document.getElementById("+i+").className='menu_top_passive'"); } eval("document.getElementById("+id+").className='menu_top_active'"); } </script> </head> <body style="margin:0; padding:0; background-color:#bbb;"> <br><br> <center> 1. Load the page.<br> 2. Click Item 4.<br> 3. Click Item 2.<br><br> Why is the bottom border of the menuelements (table cells) not getting correct in Firefox?<br> None-active menuelements should have a border-bottom = black, active should have same bottom-border as page.<br> Notice that I use border-collapse on the table in order to get the cell-border 1px thick between the menuitems.<br> If I remove border-collapse, then there is no strange behaviour in Firefox.<br> Any way to get this working in Firefox without breaking it in IE? </center> <br><br><br> <table border="0" cellpadding="0" cellspacing="0" align="center" style="border-collapse:collapse;"> <tr> <td id="1" nowrap class="menu_top_active" onClick="change('1');"><a href="javascript:;" class="menu_top">Item 1</a></td> <td id="2" nowrap class="menu_top_passive" onClick="change('2');"><a href="javascript:;" class="menu_top">Item 2</a></td> <td id="3" nowrap class="menu_top_passive" onClick="change('3');"><a href="javascript:;" class="menu_top">Item 3</a></td> <td id="4" nowrap class="menu_top_passive" onClick="change('4');"><a href="javascript:;" class="menu_top">Item 4</a></td> <td id="5" nowrap class="menu_top_passive" onClick="change('5');"><a href="javascript:;" class="menu_top">Item 5</a></td> </tr> </table> </body> </html> I'm a little puzzled by this weird display bug by IE7, this bug doesn't occur in IE6. It had to do with the DIV's CSS's border-style. If you set it to double then you notice some random bugs with it. Some of the time, the border is displayed without a problem. Some of the time, it is displayed with some gaps in the line as if it is not being drawn upon. Some of the other time, it is not displayed at all. I noticed if I switch from one tab to another then back, the border appeared as if nothing had happened. I also noticed that if I open the view source that overlapp the web browser then closed it, the border appeared as if nothing had happened. How do you fix that problem? Thanks... I'm trying to write a function that will resize a few <div>s on my page when it loads. Before I got too far, I wrote a simple function to alert the current height of each <div> to be resized. It looks like this: Code: function resizeDivs() { var saidDivs = new Array("cBodyMid", "cLeftPane", "cLeftPanelData", "cRightPaneData"); for(i=0;i<saidDivs.length;i++) { var el = document.getElementById(saidDivs[i]); curElHeight = el.style.height; alert(curElHeight); } } All I get is 4 empty alert boxes. All of the styles are defined in an external style sheet a la: Code: #myDiv { height: 25px; } and they are all assigned to <div> tags a la: Code: <div id="myDiv">here's my div</div> However, if I create a div with the height specified as an inline style, it works. I've got to be missing something really simple here. Anyone know how to get that height property? You know how you can modify Mozilla css with properties like css Code: Original - css Code -moz-border-radius: 4px 4px 4px 4px; -moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow transparent; -moz-border-top-colors: ThreeDDarkShadow ThreeDShadow transparent; -moz-border-right-colors: ThreeDDarkShadow ThreeDShadow transparent; -moz-border-left-colors: ThreeDDarkShadow ThreeDShadow transparent; -moz-border-radius: 4px 4px 4px 4px; Is it possible to get something like this to work with IE? See on F/F the box is rounded.. but on IE its just a complete square ( duh that's because I'm modding Mozilla css properties ). I see that document.getElementById('foo').style.width is a valid property, but yet I see documentation which accesses the style's properties as an array element, example: document.getElementById('foo').style['width']. Are both equivalent? What would be the property equivalent for 'text-align'??? document.getElementById('foo').style.textAlign?? Where can I find the docs for this? I am confused by the "rules" of how to indicate what you are trying to style when an element is within other elements. Specifically in this case (but hopefully this lesson will be portable to other contexts). I have a UL with an LI (classed) that is within an id'd UL that is within an id'd DIV. Code: <div id="horzmenu"> <ul id="horznavmenu"> <li><a href='rooms.php'>Accomodations</a></li> <li class='hot'>Location & Info <ul> <li><a href='/otherprops.php'>Other Properties</a></li> <li><a href='/news.php'>News & Photos</a></li> </ul> </li> <li><a href='booking.php'>Booking</a></li> </ul> </div> So if I were to wish to style this new UL and its LI's do I refer to: The parent UL as in: #horznavmenu ul ul { The parent UL and the class'd LI as in: #horznavmenu ul ul li.class{ Or? Thanks in advance for any feedback or suggested reading... I want the iframe to have a horizontal scrollbar but no vertical scrollbar. My code I've been attempting looks like this: Code: <iframe scrolling="auto" src="quicklinks.php" width="100%" height="200" name="helpContent" style="overflow-x: visible; overflow-y: hidden"></iframe> Is this possible? If so, is it compatible with all browsers? I know many of you are going to say, well you have it on auto and if you don't want it to scroll vertically, don't have a page in the iframe that is too high in height. However the page has dynamic thing submitted to it and there might be the possibility that a user submits a name too long and I don't want to deal with only showing a certain length of the string. I have a style for links that I use in my main navigation menu, like so: Code: a.main_nav { color:#FFFFFF; font-size:12px; } a.main_nav:link{ text-decoration: none } a.main_nav:visited{ text-decoration: none } a.main_nav:active{ text-decoration: none } a.main_nav:hover{ text-decoration: underline; } How can I wrap all the links in a <div> and not have to specify the class on each <a> ? Hey all, I'm developing an app for a client, and I've implemented quite a bit of it already, and it includes CSS. Code: <style> td { font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #000000; text-decoration: none; } </style> As you all might know, this changes all <td> tags into this particular style. Is there a class that I can include that contains NO properties (default)? I'm not even sure if it's possible. I just don't want to go back and add class tags everywhere. Guys I have the following issue regarding links and colours: The colours of links are set thus: a:link : White; a:hover : Blue; a:visited : White; The problem I have is that I want a hovered link to turn blue even if it has been visited. Is there anything I can do about this...? Hi! Does anybody have some great link or book advice about all the properties of the DIV and/or LAYER - tags? Inspiring examples with javascript to this are also welcome. I will use it to build advanced layer functionality. Regards Bjorn Is it necessary to declare properties like : border-bottom:none; text-transform:none; My question is why would I declare them (above) ? Is it not assumed that unless I need something like text-transform:lowercase; I should not declare text-transform:none; ...this just add up more unnecessary lines of code. What are the default properties of selectors? if not declared would it be safe to asumme that those defaul to 0, none, etc depending of the selectors? tahnks I would like to set up a table with a different border than the cells inside it. Here's my code: 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"> TABLE {border: 1px solid black; border-collapse: collapse; width: 200px} TD {border: 1px solid #ccc} </style> </head> <body> <table> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </body> </html> That's all hunky dory in (gasp!) IE, but good browsers...they only show the lighter gray color. How do I get the table border to be different? Hi, This used to be my solution: Code: <table border=1 bordercolorlight='#CCCCCC' Bordercolordark='#FFFFFF'> But this only works well on IE - not Mozilla Now I want to use CSS: Code: .results { border: 1px solid #CCCCCC ; } Code: <table class='results'> --------------- The problem is, with CSS, only the TABLE acquires the border property. The cells within it don't. If I specify Code: <td class='results'> for all the cells in the table, this also won't work, because the cell borders overlap each other and some border lines seem thicker than others (because of overlapping). Is there any simple way I can specify the border property for the table - in ONE declaration? I want the table and td borders all to be a simple 1px width ...is that possible in one declaration? Thanks a lot! Hi, I've seen things like this in CSS elsewhe Code: <style type="text/css"><!-- td[width="350"] { background-color: #FFFFFF; } --></style> The above is just an example, and it might not even be what I'm looking for. But it appears that the above would only change the background color of a table cell that is 350 pixels wide (no other table cells will be changed)? Is this how this is done? And if not, I'm trying to do something along that concept, somewhat like this: Code: <style type="text/css"><!-- table[border="2"] td .classname { color: #FFFFFF; font-family: verdana; } --></style> If this doesn't make sense, I'll try to reexplain. But if this can be done I'd be ever so grateful. Thanks! ~Kevin I've been searching for ways to graphically customise my select boxes (<SELECT>) in HTML, using CSS. So far, I've been successful in changing some basic stuff, like the background color & font, however, what I would really like to do is do more like change the border, scrollbar color etc. However, I tried doing so, but it seems to me the SELECT element isn't quite customisable this way. I checked this forum for some help, and googled my way out of this, yet no luck. So, I was wondering if someone would be able to shed some light on my issue, as I think it's really weird, being able to customise just about every form element, except the ugly default combobox... Any help appreciated! Hi Below there are three tables. first one is separated but the second one is inside the third one. Although I have set padding and border-collapse to collapse and padding to 0px but they don't appear the same size on the screen. table 3 is bigger than table 1. is there any property that I can set to 0 so table 3 appears the same size as table 1? PHP Code: <STYLE> table{ border-collapse:collapse; } td{ padding:0px; } </STYLE> <TABLE STYLE='background-color:red;width:800px;border:1px solid black;'> <TR> <TD> </TD> </TR> </TABLE> <TABLE STYLE='background-color:red;width:800px;border:1px solid black;'> <TR> <TD> <TABLE STYLE='background-color:red;width:800px'> <TR> <TD> </TD> </TR> </TABLE> </TD> </TR> </TABLE> Hi does anybody know how to set a tables properties and also give it a class name in an external css so that when i import it i only have to state the class name, instead of all of its properties. Properties such as border color, background color, cell spacing etc Cheers for the help peeps Andy |