programming4us
programming4us
MOBILE

Build Mobile Websites and Apps for Smart Devices : Style over Substance (part 2) - Rows

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

2. Rows, Rows, Rows

The next part of our app we’re going to look at are the main rows that make up the indexes of Spots and Stars. Once again, the HTML we’re going to use is fairly basic. Here’s the structure for the list of Spots:

listing 7. spots.html (excerpt)
<ul id="spots-list" class="table-view table-action">
<li>
<a href="spot.html">
<h2>Planet Hollywood</h2>
<span class="relative-distance">233m away</span>
<span class="sightings">3</span>
</a>
</li>
<li class="even">
<a href="spot.html">
<h2>Myles&rsquo; House</h2>
<span class="relative-distance">506m away</span>
<span class="sightings">5</span>
</a>
</li>
</ul>

Some points worthy of note:

  • We’re using another unordered list as the base element for our list of Spots.

  • This list has two classes that we’ll use to target all the lists that have the same structure: <table-view> and <table-action>. We’re using <table-view> to refer to all such lists, and <table-action> to identify indexes that have a single direct action.

  • The block element (<h2>) inside our link (<a>) is valid HTML5. In previous versions of HTML and XHTML, block elements weren’t allowed in this context, but HTML5 has no issue with it.

  • We’re identifying odd and even rows by an additional <even> <class> on the even rows (the absence of the class implies that the row is odd).

  • The additional metadata for each “Spot”—the distance from the user and the number of sightings—are wrapped in <span> elements with semantic classes to identify them.

To start on the style for this index, we’ll create some generic styles for all the <table-view> elements. These will be used for the indexes of “Spots,” “Stars,” and “Sightings”:

listing 8. stylesheets/screen.css (excerpt)
.table-view {
background: #7c0c18;
}
.table-view li {
border-top: 1px #8c2a34 solid;
border-bottom: 1px #640913 solid;
}
.table-view .even {
background: #830f1b;
}

At the design phase for this element, we mentioned that we need to keep performance in mind for these elements in particular. We’re staying true to that here and keeping the styles as simple as possible—relying on basic CSS like borders to create the illusion of depth without heavy images. This brings us to the point shown in Figure 3; see how the simple dark-to-light borders gives the impression that each row has a slight bezel.

Figure 3. Simple techniques like using dark-to-light borders are effective in creating depth


Now we can flesh out the elements inside each row:

listing 4. stylesheets/screen.css (excerpt)
.table-action li {
position: relative;
}

.table-action a {
color: #d6b69e;
display: block;
padding: 0.5em 0.785em 0.714em;
position: relative;
text-decoration: none;
text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 1px;
}

.table-action h2 {
color: white;
font-size: 1.285em; /* 18px / 14px */
width: 82%;
}

.table-action .relative-distance {
font-weight: normal;
}

.table-action .sightings {
background: #6f0914;
border: 1px #841420 solid;
-webkit-border-radius: 0.143em;
-moz-border-radius: 0.143em;
border-radius: 0.143em;
color: #ebc466;
font-weight: bold;
position: absolute;
padding: 0.214em 0.429em;
right: 2.5em;
top: 50%;
margin-top: -1.1em;
}


This code is all stock-standard CSS, but there are some points worth noting:

Our list is really starting to take shape now, as Figure 4 shows.

Figure 4. The elements in our list are now fully styled


This exact same code can be applied to our “Stars” list, as the underlying HTML is almost identical:

listing 10. stars.html (excerpt)
<ul id="sightings-list" class="table-view table-action">
<li>
<a href="star.html">
<h2>Caterina Fake</h2>
<span class="sightings">5</span>
</a>
</li>
<li>
<a href="star.html">
<h2>Dan Cederholm</h2>
<span class="sightings">5</span>
</a>
</li>
</ul>

Without making any changes to our CSS files, the “Stars” index will now look like Figure 5.

Figure 5. The same CSS applies to the listing of Stars


Writing modular and reusable CSS is as important as ever on mobile devices. The more generic we can make our CSS, the smaller the stylesheet our users have to download.


Tip:

Validation

Remember to validate! While even the browsers on mobile devices will do their best to deal with malformed HTML, we can make their job (and ours) a whole lot easier by ensuring that our HTML meets the W3C specifications. By ensuring our HTML is well-formed, we increase our cross-platform compatibility and minimize rendering errors. This is especially important going forward—testing against the current crop of browsers is great, but what about the browser that’s released six months from now? A year from now? Code that validates is the most reliable guarantee that future web platforms will handle it as designed.

Other  
 
Top 10
Free Mobile And Desktop Apps For Accessing Restricted Websites
MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
TOYOTA CAMRY 2; 2.5 : Camry now more comely
KIA SORENTO 2.2CRDi : Fuel-sipping slugger
How To Setup, Password Protect & Encrypt Wireless Internet Connection
Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
Backup & Restore Game Progress From Any Game With SaveGameProgress
Generate A Facebook Timeline Cover Using A Free App
New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
- Messages forwarded by Outlook rule go nowhere
- Create and Deploy Windows 7 Image
- How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
- Creating and using an unencrypted cookie in ASP.NET
- Directories
- Poor Performance on Sharepoint 2010 Server
- SBS 2008 ~ The e-mail alias already exists...
- Public to Private IP - DNS Changes
- Send Email from Winform application
- How to create a .mdb file from ms sql server database.......
programming4us programming4us
programming4us
 
 
programming4us