CSS - Context Dependency / Selectors
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 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 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> 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 ? 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; } 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'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 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. 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. 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? 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. 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 I'm trying to create a context sensitive help system so that users can click an icon and get additional information about the section of the web page they're viewing. I want a layered div to come to the top and display this information then close upon the user clicking a button / link. I have all that working fine. The problem I'm having is I only want one help layer to appear at a time. So if the user fails to close the currently open layer, i want to automatcially close this layer then display the next one. Applicable CSS: Code: .helpText { position: absolute; top: 30px; left: 10px; right: 10px; bottom: 10px; color: #000000; font-size: 13px; float:left; } .top { position: absolute; bottom: 90; left: 110; width: 100px; height:5em; background-color:#FFFF99; z-index:1; padding:.5em; border: 1px; border-style: solid; border-color: #000000; } HTML: Code: <DIV id="button"> <input type="button" name="button" value="?" onclick="helpText(\'matches\');"> <DIV id="matches" class="top" style="display:none;"> <DIV class="close"> <input type="button" name="button" value=" X " onclick="helpText(\'matches\');"> </div> <div class="helpText"> It works here too! </div> </DIV> </DIV> javascript: Code: function helpText (elm) { /* The function below successfully alters the class ".top" to not display, the problem is it works globally. So since two or more "helpText" divs will use this class even the one i want to display will be hidden. */ // alterCssClass(".top","display","none"); var div = document.getElementById(elm); if (div.style.display == "") { div.style.display = "none"; } else { changecss("#"+elm+".top","display",""); div.style.display = ""; } } Any help would be greally appreciated. Thanks in advance. 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 have one issue left in this context menu: www.webfletch.com/sharing (( Make Sure You Right Click On The Page )) The issue is in Internet Explorer, when you click on the sub-menu or one of the links in the sub-menu. Everything works fine at that point, but when you right-click to bring up the context menu again, the sub-menu comes up showing. Because technically, the css didn't grab the mouseout (Or whatever the opposite of "hover" is.) I attempted to fix this with javascript by placing different variations of different scripts all over the code that made the sub-menu style.display = 'none' However, the javascript made the code permenant. Once it was executed, the sub-menu never showed back up again. I guess javascript out-trumps the "hover" attribute of CSS. Any thoughts? Unfortunately I am going to have to get more involved in CSS rather than happily concentrating on PHP development. We have realised that getting our designers to CSS stuff is just costing us time as they lack the experience and don't understand the semantics. Anyway, as such I need to find out a few things I know but don't know if you know what I mean. Where can I find out the official definitions of CSS operators... * html for example..what the * does. class1>class2...what the > does...stuff like that. |