Forum Moderators: not2easy
#content-panels-sections div.ui-tabs-panel div.cms-body > h4:not(.full-width):nth-of-type(even), #content-panels-sections div.ui-tabs-panel div.cms-body > h4:not(.full-width):nth-of-type(even) + p:nth-of-type(even) I'm using the 'nth-of-type' selector to float odd/even sets of h4/p/img tags left and right accordingly. This works fine until one of these sets follow a h4/p tag that spans with full width without an image. At this point the next img tag will be off by 1 in the DOM tree causing it to be odd when the h4/p tags are now even.That is what I would have expected - recalling your code seems to be telling the browser to count each h4, p and img independently, so it is not counting the h4/p/img elements as a "set".
using firebug I noticed that FF was switching the order of the pseudo selectors toThere have been some reports of understanding browsers having problems with counting. Most of these relate to dynamically generated content though - so may not be relevant here. But it emphasises the importance of keeping things simple.
Is the order switching what is causing the issue, or is it just a bug in how FF (and, safari, chrome, opera) interpret the statement?Despite the known issues with counting, and the firebug report. I'd look at all the other things that will be affecting the browser beore concluding this is due to a bug.
#showcase #slideCanvas .spryEffectSlideItemContainer { ...styles }On the code provided, this could have been written :
.spryEffectSlideItemContainer { ...styles }This means that when the browser finds div.spryEffectSlideItemContainer, it does not have trace back up the document tree to make sure it is contained within the two id'ed elements. Simplifying speeds up rendering, as well as providing less opportunity for error (yours or the browser).
#content-panels-sections div.ui-tabs-panel div.cms-body > h4 ...looks like it could be simplified to
h4 ...or at worse,
div.cms-body > h4 ...If nothing else, it makes it easier for coder and browser to read ;)
... the large spanning graphic area ...Recall personal links are not allowed, so are not followed.
I tried your suggestion for simplifying some of the statements. As I thought I run into issues of specificity ... when I remove everything before 'div.cms-body'.Am not sure if you mean you thought simple selectors would create issues, or if specificity issues arose after you tried to simplify.
The reason I have tried everything ... to avoid this, is to allow very simple creation/editing ... Ideally I'd like someone ... to create/edit a page using a "cheat sheet" so that as long as they follow the proper structure the proper styles would be applied. Requiring lots of class specifications ... increases the likely hood that the page will break and since the default style is alternating sides, having to apply a class would not be very efficient.One purpose of the css3 selectors is to allow the creation of more efficient code. That is, efficient for humans to write, browser and human to read, and browsers to process.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"Note this assumes the images/paras should alternate left/right down the page. If that is wrong, or this doesn't help, please post some code.
"http://www.w3.org/TR/html4/strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title My title</title>
<style type="text/css">
/*Styles for example */
.content {
width:40%;
background-color:#aaa;
margin: 0 auto;
}
.wrap {
width:90%;
background-color:#bbb;
margin: 1em auto;
}
/*basics styles for the h4, p, img sets */
.wrap p {
width:45%;
float: left
}
/* create the alternating float*/
.wrap:nth-of-type(2n+1) p {
color:blue;
float:right;
}
</style>
</head>
<body>
<div class="content">
<div class="wrap">
<h4>One</h4>
<p>My para</p>
<img src="insert image" width="50px" height="50px">
</div>
<h4>My full width title</h4>
<p> my full width para </p>
<div class="wrap">
<h4>Two</h4>
<p>My para</p>
<img src="insert image" width="50px" height="50px">
</div>
<h4>My full width title</h4>
<p> my full width para </p>
<div class="wrap">
<h4>Three</h4>
<p>My para</p>
<img src="insert image" width="50px" height="50px">
</div>
</div><!--end column of content-->
</body>
</html>
$(function() {
$("div.cms-body > h4:not(.full-width):odd, div.cms-body > h4:not(.full-width):odd + p").css({'float' : 'left', 'padding-right' : '5px', 'padding-left' : '0'});
$("div.cms-body > h4:not(.full-width):odd + p + img").css({'float' : 'right'});
$("div.cms-body > h4:not(.full-width):even, div.cms-body > h4:not(.full-width):even + p").css({'float' : 'right', 'padding-right' : '5px', 'padding-left' : '0'});
$("div.cms-body > h4:not(.full-width):even + p + img").css({'float' : 'left'});;
});
At this point, if there is no way to correct how the browsers are 'counting', ...To me, the thread has still not addressed this original issue.