CSS - [css3] Selectors Problem
Hi all,
I'm having an issue using CSS3 selectors. I'm not quite sure if this is even possible but here it goes. Imagine the HTML below: html4strict Code: Original - html4strict Code <tr> <th><input type="checkbox" name="cb" /></th> <td>Something here</td> <td>Someting here also</td> </tr>
Is it possible with CSS to utilize the :checked selector on "tr th input:checked" and somehow set the background color for the td-s? I've tried several combinations but to no avail. And as far as I know there's no parent selector or anything that lets you traverse backwards and I'm trying to avoid JavaScript as much as possible. I'm using Firefox 2.0.0.12. Similar TutorialsHi all, could someone please explain to me the difference between ID selectors - #idselector {ksjdfkjd} and class selectors - .classselector {askdjfak} ? I am just becoming more familiar with CSS and I'm not sure when I should use which. Thanks I have the following CSS styles: Code: #content p { font-size: 24px; } .smalltext p { font-size: 12px; } Then, I create a #content div in my HTML with three paragraphs in it. I want the middle paragraph to have the .smalltext class, like this: http://www.toprival.com/temp/css_question.gif With the CSS the way I have it, the font size (12px) of the .smalltext paragraph is ignored. But if I change the CSS so both selectors are IDs, or so both are classes (and update the HTML accordintly), it works. Why is that? I want to style something based on what comes after it. If a div is the last to have the class "combinedyes" I want to make the text red for example. I've experimented with: #EditMedHistoryDisplay div.cmMed.combinedyes + div.cmMed.combinedno But that styles the combinedno element... Any ideas? Code: <div id="EditMedHistoryDisplay"> <div class="cmMed odd combinedyes">Testosterone 2 mg <span class="medicationDelMethod">Cream-Transdermal</span> <div class="cmNotes ecmInstructions" id="cmnotes_21158" title="Click to edit" style="background-color: rgba(0, 0, 0, 0); ">1 Gm (1 Gm = 1/4 tsp = 2 pumps)</div> </div> <div class="cmMed even combinedyes">DHEA 10 mg <span class="medicationDelMethod"> Cream-Transdermal</span> <div class="cmNotes ecmInstructions" id="cmnotes_21194" title="Click to edit" style="background-color: rgba(0, 0, 0, 0); ">1 Gm (1 Gm = 1/4 tsp = 2 pumps)</div> </div> <div class="cmMed even combinedyes">Test 10 mg <span class="medicationDelMethod"> Cream-Transdermal</span> <div class="cmNotes ecmInstructions" id="cmnotes_21184" title="Click to edit" style="background-color: rgba(0, 0, 0, 0); ">1 Gm (1 Gm = 1/4 tsp = 2 pumps)</div> </div> <div class="cmMed even combinedno">Testosterone 2 mg <span class="medicationDelMethod"> Patch-Transdermal</span> <div class="cmNotes ecmInstructions" id="cmnotes_21038" title="Click to edit">It's a patch...</div> </div> </div> I'm trying to get my head round these ... A) .search input, .search .commonButton { margin-right: 7px; vertical-align: middle; } I know what the style parts do, but I don't understand what the first two lines are doing. I think the second line is saying to apply the style to all .commonButton classes within a .search class ??? Don't know about the first. -------------------------------------- B) .buttons div { white-space: nowrap; } does this mean the style is applied to any div elements within the .buttons class? I am trying to style the <hr> in the following peice of my page using css selectors. I have used,
Code: td div hr {...} , but this affects other hr's outside of this menu. Is there a way to make this work without having to give the hr a class name? Thanks. Code: <td width="140" bgcolor="#EFBE56" class="Menu_WhiteText_GoldBkgd"><div align="left"> <p class="side_menu_white"><br> <a href="In-The-News.htm" style="color: white">in the news...</a> </p> <p class="side_menu_white"> <a href="Press_Releases.htm" style="color: white">press releases</a> </p> <p class="side_menu_white"><a href="Newsletter.htm" style="color: white">newsletter</a> </p> <p class="side_menu_white"><a href="Multimedia.htm" style="color: white">multimedia </a></p> <p class="side_menu_white"><a href="../About/annual_reports.htm" style="color: white">annual reports</a> </p> <p class="side_menu_white"><a href="Contact.htm" style="color: white">contact media relations & communications</a> </p> <hr> <p><span class="Menu_WhiteText_GoldBkgd"> <a href="PhotoRelease-ConsentForm.pdf" target="_blank">consent form</a> </span> <span class="Body_Text2"><span class="Body_Text"><br> <br> </span></span></p> </div></td> I am displaying a Google feed on my site through an asp script that converts RSS to HTML. There is no room for images where the feed is, so we just take them out by setting display: none;. That solves one issue, but then the text is way off. I'm having trouble acessing the text after the picture so I can use absolute positioning and keep it left justified. See http://www.lsuhospitals.org/Hospitals/Bogalusa_Med_Center.htm for an example. Here's the RSS to HTML source tabbed out as best I could. This conversion isn't perfect and still needs some work. What's in red is what I need CSS access to, but only when an image is present. Whew! Code: <html><head><title></title><LINK REL="StyleSheet" HREF="../../StyleSheets/HCSD.css" TYPE="text/css" MEDIA="screen"><style>body{margin: 0px; padding:0px; background-color:white;}</style></head><body> <table width="140px" class="BodyTextHeading1" cellspacing="0" cellpadding="0"> <tr> <td> BMC IN THE NEWS </td> </tr> </table> <table> <tr> <td class="rsscontainer"> <br> <table border=0 width= valign=top cellpadding=2 cellspacing=7> <tr> <td valign=top> <a href="http://news.google.com/news/url?sa=T&ct=us/0-0&fd=R&url=http://www.edailynews.info/articles/2007/01/04/news/news04.txt&cid=0&ei=RKemRfDvO8qMsgGgwJmXDQ"> Two perish in accidents as 2006 comes to close </a> <br> <font size=-1> <font color=#6f6f6f> Bogalusa Daily News, LA - </font> <nobr> Jan 4, 2007 </nobr> </font> <br> <font size=-1> Bonnett said the incident is still being investigated and oxicology tests are still being conducted. The initial 911 call was made to WPSO and came from the LSU-<b>Bogalusa Medical Center</b> where Johnson had been brought by private vehicle. </font> <br> </table> </td> </tr> <tr> <td class="rsscontainer"><br> <table border=0 width= valign=top cellpadding=2 cellspacing=7> <tr> <td width=80 align=center valign=top> <a href="http://news.google.com/news/url?sa=T&ct=us/1i-0&fd=R&url=http://www.edailynews.info/articles/2007/01/02/news/news04.txt&cid=0&ei=RKemRfDvO8qMsgGgwJmXDQ"> <img src=http://news.google.com/news?imgefp=lpU8D0_YzTEJ&imgurl=www.edailynews.info/content/articles/2007/01/02/news/news04.jpg width=79 height=37 alt="" border=1> </a> </td> <td valign=top> <a href="http://news.google.com/news/url?sa=T&ct=us/1-0&fd=R&url=http://www.edailynews.info/articles/2007/01/02/news/news04.txt&cid=0&ei=RKemRfDvO8qMsgGgwJmXDQ">Tim Augustine, Regina Runfalo to reign over MCCA XXVII festivities</a> <br> <font size=-1> <font color=#6f6f6f> Bogalusa Daily News, LA - </font> <nobr>Jan 2, 2007 </nobr> </font> <br> <font size=-1>Runfalo, a registered nurse, serves as assistant administrator of LSU <b>Bogalusa Medical Center</b>, where she has been employed 26 years. </font> <br> </table> </td> </tr> </table> And here are the relavent styles that I created. I have consulted my book "The Web Professional's Handbook" by glasshaus publishing. They have a decent CSS section (selectors on pgs. 96-97), but to no avail. Code: .rsscontainer { font-family: Verdana; color: black; width: 140px; background-color: white; padding: 0 0 0 0; margin: 0 0 0 0; } .rsscontainer table tr td font{ font-size: 10px; line-height: 1.3; } .rsscontainer table tr td a img { display:none; } .rsscontainer table tr td a { font-family: Verdana; font-size: 10px; color: #461D7C; text-decoration: underline; } .rsscontainer table tr td a:hover { font-family: Verdana; font-size: 10px; color: #7549B1; } .rsscontainer table tr td a:visitied { font-family: Verdana; font-size: 10px; color: #7549B1; text-decoration: underline; } It would be a great idea to have some html type viewer, or FF plugin that would show you the slectors of an html document. Does anyone know of something like this ? I'm trying to learn css and if I could just highlite some text in the html document and it would display the possible selectors for that selection I think it would be a great learning aid. Any ideas ? Hi. I like to know what're the differences. I know that css3 has more properties. It can do rounded corner border easily and also some new ways to write css. Is this css3? input[type="submit"] Also I remember seeing websites mentioned css3 can be written in module or something like that? What other differences? Thanks. Hi everyone, I am new to this website as well as CSS for the most part. I have been working on a wordpress themed website recently trying to learn as much as possible. My website is self-hosted currently so can't really give you a link to view my code. I just discovered the CSS validator and I validated my CSS file. It contains 13 errors (yikes!) and 16 warnings. However, I don't really know how to interpret it. I use notepad++ as an editor. The profile I used is CSS level 2.1: EDIT: Here is the new code for CSS 3. I only copied the errors part. Code: 23 .socialmedia img Property -webkit-transition doesn't exist : all 0.2s ease-in all 0.2s ease-in 24 .socialmedia img Property -moz-transition doesn't exist : all 0.2s ease-in all 0.2s ease-in 25 .socialmedia img Property transition doesn't exist : all 0.2s ease all 0.2s ease 38 .socialmedia img.fade:hover Property -moz-opacity doesn't exist : 1 1 39 .socialmedia img.fade:hover Property -webkit-transition doesn't exist : all 0.2s ease-in all 0.2s ease-in 40 .socialmedia img.fade:hover Property -moz-transition doesn't exist : all 0.2s ease-in all 0.2s ease-in 41 .socialmedia img.fade:hover Property transition doesn't exist : all 0.2s ease all 0.2s ease 60 #main-nav-search Value Error : padding-top -1.0 negative values are not allowed : -1px -1px 79 .menu2-top-right Value Error : border Too many values or values are not recognized : solid 0 1px 1px 1px #000 solid 0 1px 1px 1px #000 80 .menu2-top-right Property -moz-border-radius-bottomright doesn't exist : 10px 10px 10px 10px 82 .menu2-top-right Property -moz-border-radius-bottomleft doesn't exist : 10px 10px 10px 10px 87 .menu2-top-right Property -moz-box-shadow doesn't exist : 3px 3px 6px #7f7f7f,8px -10px 10px #7f7f7f 3px 3px 6px #7f7f7f,8px -10px 10px #7f7f7f 88 .menu2-top-right Property -webkit-box-shadow doesn't exist : 3px 3px 6px #7f7f7f,8px -10px 10px #7f7f7f 3px 3px 6px #7f7f7f,8px -10px 10px #7f7f7f What does it mean when it says "doesn't exist"? What is the Difference between CSS2 and CSS3 ??? Hi, I'm building a page that imports two blog feeds from feedburner displaying them in separate divs. I'm a beginner at CSS and could use some help manipulating the styles of these blog feeds separately (which are linked to an external style sheet), but I don't know enough about context dependent css and selectors. I've tried researching a solution but haven't found an answer specific to what I'm doing. I've given the divs their own IDs ("newsblog" and "newcontent"). Here's an example of some of Google's css: div.feedBurnerFeedBlock li a:link { font-size: 20px; font-weight: bold; font-color: #9F0; font-family: Verdana, Geneva, sans-serif; text-decoration: none; list-style-type:none; } I need to take that code and make it specific to one div or the other, instead of applying to both. Any help or advice is greatly appreciated. Thanks, Jeff I am using CSS in the context of an SVG document. In SVG, we use element names like 'rect', 'circle', & 'polyline' rather than 'p', 'table' and 'form' as HTML coders are familiar with. I am trying to apply a generic style to all 'rect' elements, and then modify that style with class styles. The styles: Code: rect{ fill: black; stroke: yellow; pointer-events: none; .... other SVG styles .... } .frame{ fill: black; stroke: magenta; --- other SVG styles.... } In the document, I use a 'rect' element, and apply the class style to it: Code: <rect class="frame" height="5088" id="Rect_37" width="6688" x="-1008" y="-1728" /> As you may notice, there appears to be a contradiction in the styles specified by the two selectors: 'rect' and 'frame'. One would have the element rendered with a magenta outline, while the other would outline with yellow. In practice, the stroke rendering seems to inherit from the 'rect' element style, although this seems counter-intuitive to me (class styles seem to be more specific than element styles). In researching this, I have actually found nothing that clarifies the question. Even the W3C site seems to ignore the case, as far as I can tell. Is this even valid CSS? If yes, what rule dictates how the document will get rendered? I have passed the entire SVG doc through the XML validator, but the CSS validator only accepts HTML & raw CSS. What would be the correct method of applying a global per-element-type style, but modifying it for specific instances of such elements? I am trying to keep the document as small as possible, and reduce the need for redundant style information, as this seems to have a significant impact on performance of the rendering (presently only tested using Mozilla Seamonkey) I'm pretty much of a CSS newbie, so feel free to correct whatever jargonology I've mangled. Pointers to definitive references most welcome. Thanks. --- rod. i have two p tags one after the other.. <p>text</p> <p>text</p> and I did: Code: #head p { float:left; margin-top:2%; font-style:oblique; font-size:150%; color:green; } #head p+p { float:right; font-size:75%; color:red; } the problem is that if i do margin-top:4% to the first p; this also changes that in the adjacent p? is this correct? So my code works fine in webkit(Safari/Chrome), and it almost works in Firefox. If you want to try it out for yourself, just make sure you use a large image, like 500x500 pixels or larger so you can see what I mean. In the tutorial I watched they were able to make it work in Firefox, and the video is almost 1yr old, so it should work. Code: <html> <head> <title>Background Size and Images</title> <style> body { background: blue; margin: 0; padding: 0; } #container { background: white; width: 75%; height: 600px; padding: 50px; margin: 1em auto; } #container div { background: tan; border: 1px solid; margin-right: 50px; float: left; } #container #one { width: 80%; height: 100px; background: url(samplesample.png) no-repeat; -webkit-background-size: 100%; -moz-background-size: 100%; } #container #two { width: 150px; height: 50px; background: url(samplesample.png) no-repeat; -webkit-background-size: 150px 50px; -moz-background-size: 150px 50px; } #container #three { width: 100px; height: 250px; background: url(samplesample.png) repeat; -webkit-background-size: 25px 25px; -moz-background-size: 25px 25px; } </style> </head> <body> <div id="container"> <div id="one"> </div> <div id="two"> </div> <div id="three"> </div> </div> </body> </html> I'm currently having a problem getting the opacity to work. I haven't tried using RGBa yet, but it should work the same as HSLa, and right now HSLa isn't working properly. Usually when I've had a problem, it's just a matter of moving the file around in my finder(I use a Macbook) or I've missed a semi-colon or quotation mark or something.....but with this, I swear I've checked, double-checked, triple-checked everything and it's not working. And I've checked it in Safari, Chrome, and Firefox. Right now I have the Alpha element in the HSLa set to .25, which means it should be quite transparent...but all it does is make the color lighter, not transparent. If I could somehow send someone my files/images and screenshots for you to try and help, that'd be great. Otherwise I'm not sure how to go about getting help. Thanks! This is driving me nuts! I have done everything I think that they says I should do but it is not working...here is the table style I am using if I use normal border styles it works ok...please can someone tell me where I am going wrong...thank you! .nik { background-color: #FFEAA1; padding-left: 1em; padding-right: 1em; border-image: url(border.png) 0% 30% 0% 30% repeat; } oh and the image size is 100px x 100px Kriss I got transitions to work using a simple hover, but how do i make them respond to onclick? Code: <html> <head> <style> #trans { opacity:100; transition: all 1st ease-in-out; } #trans:hover { opacity:0; } </style> </head> <body> <img src="myimage.jpg" id="trans" /> </body> </html> Hi everyone, So I've been coding for years and had drawn away for the design/css part, so I need some refreshing. I've tried the greater than / less than "operators" between selectors in my css declaration but to no avail. Basically what I want to do is example: Code: <form><!-- really doing this basic just to show the point --> <fieldset> <!-- inputs here --> </fieldset> <fieldset> <fieldset><!-- ### nested fieldset inside fieldset, don't want to affect these child selectors --> <!-- input bla --> </fieldset> </fieldset> </form> So as you can see in my brief exampl above, there's two parent selectors and one child inside the second one. I only want to change the properties of the parent ones, so that a fieldset INSIDE a fieldset doesn't get affected, and I was hoping anyone here might be able to shed some light on how to achieve this. Many thanks Here's a handy tip for you ... if like me you split your big stylesheet up into smaller ones, put them into a linked stylesheet and import them, like so: PHP Code: <link rel="stylesheet" type="text/css" href="main.css"> and in the CSS file itself ... PHP Code: @import url(css/file1.css); @import url(css/file2.css); @import url(css/file3.css); @import url(css/file4.css); some of you no doubt will already do this. here's the crux tho. if you also have some miscellaneous CSS which doesn't fit in any of the extra files and are going to include them in the linking [main] file, then you must include them after the import statements. if you don't Mozilla will ignore the imports and the extra files will not be included in the rendering. code should be like this: PHP Code: @import url(css/file1.css); @import url(css/file2.css); @import url(css/file3.css); @import url(css/file4.css); body { direction: rtl !important; } IE get's this correct regardless of the order. |