Sample CSS Code Snippet for Responsive Page Wrappers
Use the following as a guide to creating the CSS required to make a Page Wrapper responsive. You can add to the CSS rules to hide additional links or style the elements differently at each snap point.
The top snippet defines a grey block header that looks similar to the following when displayed on a personal computer or tablet:
<style>
div.wrapper-header {
padding: 15px;
background-color: #f0f0f0;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
}
div.nav-content {
float: left;
}
ul.nav-links {
background-color: #ffffff;
padding: 10px 30px;
margin: 10px 0;
list-style-type: none;
margin: 0;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
ul.nav-links li {
width: 140px;
text-decoration: none;
display: inline-block;
zoom: 1;
vertical-align: middle;
}
ul.nav-links a.nav-link {
color: #1598f2;
}
div.login-fields {
float: right;
}
div.login-fields {
float: right;
}
input.log-button {
border: 1px solid #1598f2;
color: #1598f2;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
div.user-field label {
width: 70px;
display: inline-block;
zoom: 1;
}
input.login-input {
width: 90px;
}
div#OAuthLink {
margin-top: 15px;
}
div#OAuthLink div.loginText a {
display: none;
}
div#OAuthLink img.loginLinks {
margin-right: 4px;
}
div#newUserLink,
div#troubleSigningInLink {
display: none;
}
</style>
You can add device media statements to specify the size and change the CSS for different devices, such as removing a border. The following sample snippets show how to code the media statement and some basic CSS that you can add or change.
To accommodate the screen size of a:
- Tablet: Enter code similar to the following above the </style> tag:
<!-- Tablet Layout -->
@media only screen and (min-width: 768px) and (max-width: 991px){
.mobile div.nav-content {
width: 470px;
}
.mobile img#banner_image {
width: 358px;
}
.mobile img#logo_image {
width: 103px;
}
.mobile ul.nav-links li {
width: 130px;
}
}
Smart Phone Portrait: This is the default vertical view. Enter code similar to the following above the </style> tag to make the layout adjust as follows:
<!-- Smart Phone Portrait Layout -->
@media only screen and (max-width: 767px) {
.mobile img#banner_image,
.mobile div.login-fields {
display: none;
}
.mobile div.nav-content {
float: none;
text-align: center;
}
.mobile ul.nav-links li {
width: 105px;
}
}
- Smart Phone Landscape: Enter code similar to the following above the </style> tag:
<!-- Smart Phone Landscape Layout -->
@media only screen and (min-width: 480px) and (max-width: 767px){
.mobile img#banner_image,
.mobile div.login-fields {
display: none;
}
.mobile div.nav-content {
float: none;
text-align: center;
}
.mobile ul.nav-links li {
width: 115px;
}
}