Eric lippert - Amazon Web Services
Eric lippert - Amazon Web Services
Eric lippert - Amazon Web Services
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
computers, so we’ll call this the Tablet settings. But instead of<br />
creating a third settings file, we’ll simply put the styles in the<br />
media-browser-hd.css file. You may choose to do this if there are<br />
common styles between the two form-factors, or you can go the<br />
separate file per form-factor route. I am doing it for academic<br />
reasons here.<br />
Open the media-browser-hd.css and put in the following<br />
@media only screen and (max-width: 1024px) {<br />
}<br />
This implies that the enclosing styles will be applicable to<br />
browsers up to the width of 1024 pixels.<br />
We adjust our style accordingly and the final set of styles are as<br />
follows:<br />
.imageColumns {<br />
margin: 5px;<br />
}<br />
Set Margin to 5px instead of 10 in the desktop style.<br />
.mediaImage {<br />
max-width: 85%;<br />
max-height: 150px;<br />
}<br />
Set max-height to 150 to match the height of the mediaDiv<br />
.mediaDiv {<br />
float: left;<br />
width: 24%;<br />
margin: 1px;<br />
height: 150px;<br />
border: 1px solid #7ba9ca;<br />
display: table-cell;<br />
vertical-align: middle;<br />
text-align: center;<br />
}<br />
Set the Width to 24% giving us about 4 images per line and the<br />
height to 150px so that landscaped images don’t look too odd.<br />
h3 {<br />
font-family: ‘Segoe UI’;<br />
font-size: 0.7em;<br />
}<br />
Finally we update the font-site to be 0.7em<br />
Updating the Media query for the<br />
media-browser-hd.css<br />
Now that we’ve two types of styles defined in one CSS file, we have<br />
to ensure that the file is actually included for both types. We revisit<br />
the Index.cshtml and update the condition to include<br />
media-browser-hd.css as follows<br />
<br />
Essentially instead of declaring a minimum width of 1025px, we’ve<br />
reduced it to 481px so that the desktop style sheet (*-hd.css) is<br />
included for any screen 481 pixels and above. Thanks to the<br />
inner media query that has a max-width set to 1024, screen width<br />
between 481 and 1024 are handled by the tablet styles, inside the<br />
inner query.<br />
We are all set, let’s run the application and search for images<br />
posted by the Twitter user ‘fascinatingpics’. I have composited the<br />
images from each form factor but we can see our media queries<br />
are in action and each form-factor shows a layout that looks nice<br />
and appropriate for the screen size.<br />
DNcmagazine www.dotnetcurry.com | 55