Responsive price list - how to shade alternate rows?
Teetime
Registered Users Posts: 202 Major grins
I'm working on a responsive price list for my site. Here is the link: http://www.takeonesolutions.com/Price-List. The code is below. I'm trying to use CSS nth-of-type(odd) to color alternating rows but I'm not getting it right. How is the best way to achieve this?
<body> <div id = "row"> <div class="item"> <p>This is a short entry.</p> </div> <!--closing div class for "item"--> <div class="price"> <p>$100</p> </div><!--closing div class for "price"--> </div> <!--closing div class for "row"--> <div id = "row"> <div class="item"> <p>This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on.</p> </div> <!--closing div class for "item"--> <div class="price"> <p>$2100</p> </div><!--closing div class for "price"--> </div><!--closing div class for "row"--> </body>
* { box-sizing: border-box; } .item { width: 80%; float: left; padding: 10px } .price { width: 20%; text-align: right; float: right; padding: 10px } .row:nth-of-type(odd) { background: green; }
Jerry
0
Comments
And also not the customize link.
...../Price-List/n-xxxxxxx
BTW, you can not use a tag, only one can exist on a page and Smug is already using it.
You can only use an ID name once on a page. You have two "row" defined.
Try
My Website index | My Blog
Allen, not sure what you mean by n-xxxxxxx. Also, this is a page, not a gallery if that makes any difference.
Thanks for the info re <body> tag and ID name. I've corrected those two items but I'm still not getting color on alternating (or any) rows.
http://www.takeonesolutions.com/Price-List
My Website index | My Blog
With no height defined I don't think background would apply. Also be careful not to use any class
name that Smug already defines site wide, otherwise you'll be using a lot of "!important" to override. I have found when using floats in any html box that the clear floats is needed at the html end not to
interfere with the rest of the page. I believe a spacer GIF also works.
My Website index | My Blog
http://www.takeonesolutions.com/Price-List
HTML
[html]
<div class="row">
<p class="price">$100</p>
<p class="item">This is a short entry.</p>
</div>
<div class="row">
<p class="price">$2100</p>
<p class="item">This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on.</p>
</div>
<div class="row">
<p class="price">$4000</p>
<p class="item">This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on.</p>
</div>
[/html]
CSS
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
You are going to have to call a specific height to make it work.
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
The problem I'm having with that is you have to specify enough height to vertically span the text on a mobile device. This results in a large amount of shaded space between the bottom line of text and the start of the next row when on a large monitor.
I've decided to go more with Allen's concept but add a horizontal separator line between line items in my price list. But I'm having a problem with that. I would appreciate it if one of you could look at the code and tell me what I'm doing wrong. Basically I've created a wrapper class "service" and I am decorating it with " border-bottom:1px gray solid". My expectation is it would draw a horizontal line beneath each "service" line item, but it is rendering it only once, after the "Packages" category.
http://www.takeonesolutions.com/Price-List
Here is what I would like for it to look like:
HTML
[html]
<div class="line"></div>
[/html]
CSS
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
[html]
<div class="row">
<p class="price">$100</p>
<p class="item">This is a short entry.</p>
</div>
<div class="line"></div>
<div class="row">
<p class="price">$2100</p>
<p class="item">This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on.</p>
</div>
<div class="line"></div>
<div class="row">
<p class="price">$4000</p>
<p class="item">This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on. This is a long entry in the price list that will wrap on mobile displays because it goes on and on and on.</p>
</div>
[/html]
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
Mike, that code looks like the earlier test version. I'm curious, looking at the current code at http://www.takeonesolutions.com/Price-List vs the code in this example, what did I do different that is preventing me from getting the results they show?
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
Mike, when I add your line code in I get the same result (one line under the "Packages" line), so there is something in my code that is wreaking havoc. Can you see anything here? This is the my code before adding your line code. You can see this at http://www.takeonesolutions.com/customize/Price-List:
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk