Jump to content
  • Announcements

    • boen_robot

      Guidelines and Netiquette   03/28/2017

      Posting Problems:   Having problems posting your topic? Read through this: To join, you agree to our terms and conditions and fill out and submit a registration form. An activation email will be sent to your email adress, so you'll need to verify your account. After that the account has to be validated by one of the moderators. This will mean that it can take up to a day to be activated. A couple of things to remember to ensure approval: Don't use an email address in one of those $2 four character .com domains eg. xyds.com. These will be deleted and the domain added to the banned list. Don't use an email address that is within a domain with a bad reputation for spam. A Google search is run on every email address and email domain. Don't sign up with an email address that doesn't exist, doesn't work or requires the sender to answer a quiz before their email can get to you. Put your country and or state and city in the signup form. Blank forms will go to the botton of the "to do" list. And make sure that your email address and your country match, saying you're from Alabama and using a .ru email address is not going to get you activated. After a membership is activated the first few posts will be monitored. Posting spam or unapproved topics described in the agreement results in an immediate ban. The email provider and the IP addresses associated with the account will be banned and all posts will be deleted. These strict measures have been deemed necessary to hinder spam. Sorry for any inconvenience this causes, but it's not liable to change. If, after reading this, you still can't post and don't understand why, contact one of the Moderators listed here.   Topic Guidelines   Including the following information can expedite an accurate response from board members: Must be a Specific Problem or Question related to web design and development Include Code in Question (wrap with   for small blocks of code and for longer blocks   ) Include Code Author Include Extra Notes/Modifications/Attempts Include web link to page/file when possible Content Guidelines   You may not post, upload, link to, or email any Content that contains, promotes, gives instruction about, or provides prohibited Content. Prohibited Content includes any Content that breaks any local, state, county, national or international law. Prohibited Content also includes: No direct or indirect advertising or websites, forums, products, services No hijacking of posts (do not post your question in someone elses) Content that infringes upon any rights [ex. MP3s and ROMs] (including, but not limited to, copyrights and trademarks) Abusive, threatening, defamatory, racist, or obscene Viruses or any other harmful computer software False Information or libel Spam, chain letters, or Pyramid schemes Gambling or Illicit drugs Terrorism Hacking or cheating for internet/online games Warez, Roms, CD-Keys, Cracks, Passwords, or Serial Numbers Pornography, nudity, or sexual material of any kind Excessive profanity Invasive of privacy or impersonation of any person/entity Hacking materials or information Posting Tips   There are more BBcodes than there are buttons for on the reply menu. To get the full list, click "BB Code Help" underneath the clickable smilie face menu. Use   for small snippets of code Use   for lengthy snippets of code Use   if your snippet is HTML (optional) Use   if your snippet is SQL (optional) Rules of Conduct   Be nice. There's no need for calling someone stupid if they ask an 'easy' question. Keep your avatars and signatures absolutely child friendly. We have a younger audience on this forum. Keep your language appropriate for the same reason above. Do not PM moderators for help on the forum. Post on the topic, or create a new one.   Spam:   Recently, as you have all without doubt noticed, we have had lots of spam and advertisement on the forum. Therefore, we'd like to alert you as to what to do when you have found any of the aforementioned annoying messages: it. Immediately. Give a clear reason, please, if the advertising is not evident. DO NOT POST! Report, let the post stay as is, and we will get to it, meanwhile if you continue to post as normal in the other threads, it won't be on the top so long. Refrain from PMing the member. This won't help at all, as they are most likely spambots anyway. Thank you.       Images in signatures:   After thinking of users on dial-up, we have decided to enforce the following rules regarding signatures. Please pay heed to them. Respecting these rules is respecting the members on this forum with dial-up. Signature rules: No animated images AT ALL. No matter the amount of animation. Maximum image widthxheight: 300x150 Maximum image (file) size: 15kb Use calm colors. Do not use highly contrasting images in your signature, as this can get really annoying when seeing several posts from one member in the same thread. The same prohibited content goes for images as for posts. Lastly, use common sense. No lengthy signatures please. Save us some scrolling. Thank you.       Links in signatures:   Please understand that w3schools.com only exists because of voluntary work and is barely supported by the advertising littered throughout the tutorials and the forum. So, please, stop advertising other sites. DO not post links that drive traffic away from the w3schools domain - especially to a site that offers similar if not identical information. Please help support the site by keeping individuals on it. Thank you. Here are some guidelines as to what you can put in your signature: w3schools links --> allowed w3.org links --> allowed browser links --> allowed html editor links --> allowed personal sites --> allowed tutorial sites competing with w3schools --> NOT allowed sites completely irrelevant to webprogramming and this forum --> NOT allowed   Thanks for understanding, and for taking the time to read this. ~W3Schools Modstaff~

Secrets of CSS- Responsive Layouts

Recommended Posts

After following the tutorials for CSS and HTML, there are still unanswered questions when it comes to putting it all together. From the tutorials, you learn that each CSS declaration follows this pattern (be careful for every keystroke and line feed)



selector3 {

style designator1:style1;

style designator2:style2;

style designator3:style3;

style designator4:style4;


You can also use a single line, although it is harder to read and remember what it means.

selector1, selector2,selector3 {style designator1:style1;style designator2:style2;style designator3:style3;style designator4:style4;}

This article will lend some insight into the inner thoughts of designers for Wordpress themes, specifically twentytwelve theme using the top navigation menu as the example.


All code is executed sequentially. This means that if you declare a style higher up on the page, then you can undeclare it lower down. It also means that you can declare different styles in a top-down approach of increasingly narrower specificity. For instance, begin at the top and select all Object types for the most general style. Then select a subset of those types to single out for a different style. Continue to the most specific selector last.


Selectors can be declared by any of three designator types (in increasing specificity)

Object Type (object)

Group Name (class)

Individual Name (id)

and combinations of designators using container-within-container approach.

Individual Name Object Type (id object) #this-id div{}

Group Name Object Type (class object) .this-class a{}

Individual Name Group Name Object Type (id class object) #this-id .this-class a{}

Other selectors follow a train of descendents and ancestors to arrive at the selection group.

.class1 .class2 .class3 object

(this part is a little fuzzy because sometimes you need the ancestors, and other times you don't)


Finally a special trick for navigation menus

.sub-menu a:hover > ul {display:hidden;} /*hide the hover feature for smartphones/

For hover mode on a sub menu item you wish to hide it until you hover over its parent. Later you will want to use 'display:inline-block;' or 'block;' for mobile devices since hover does not work on these devices.



When you declare a style for a selector and then want to remove part of that style, you can simply declare it again and use the style 'none'.

Example: Begin by setting color, background color, font and other major styles that will permeate all elements regardless of screen size. Then repeat the selector for the smaller screen and change only those styles that are to be changed.

.main-navigation a{color:white;background:blue; font-weight:normal;font-size:12px;}

Minimal code to get the job done requires both a top-down sequence and an outer-to-inner selection strategy for selectors and styles.



To get css to respond to screen size, use this command

@media screen and (min-width:600px){

/*code styles here for all screens larger than 600 pixels*/




Note: To follow this code example, create a child theme and copy the style.css file from twentytwelve into the child theme. This way you will retain your style with any theme updates.


twentytwelve theme uses top-down to designate navigation for smart phone styles first and then overrides these styles for screens larger than a minimum width. It begins with showing the Menu button for smartphones.



/* Navigation Menu above other navigation groups/.main-navigation {/*set styles for navigation container) margin-top: 24px; margin-top: 1.714285714rem; text-align: center;}.main-navigation li { /*set display for all navigation link items/ margin-top: 24px; margin-top: 1.714285714rem; font-size: 12px; font-size: 0.857142857rem; line-height: 1.42857143;}.main-navigation a { /*set text color for all links in the menu/ color: #5e5e5e;}.main-navigation a:hover,.main-navigation a:focus {/*set hover text color for all links in the menu/ color: #21759b;}.main-navigation ul.nav-menu,.main-navigation div.nav-menu > ul {/*hide menu for smartphones—overridden later/ display: none;}.main-navigation ul.nav-menu.toggled-on,.menu-toggle {/*display toggle button for smartphones—overridden later/ display: inline-block;}

/* Minimum width of 600 pixels. Now override styles for all screens larger than smartphones*/@media screen and (min-width: 600px) {


.main-navigation ul.nav-menu, .main-navigation div.nav-menu > ul {/*style for all top level links/ border-bottom: 1px solid #ededed; border-top: 1px solid #ededed; display: inline-block !important;/*this displays the top level navigation links/ text-align: left; width: 100%; } .main-navigation ul {/*new style for link containers/ margin: 0; text-indent: 0; } .main-navigation li a, .main-navigation li {/*display all links/ display: inline-block; text-decoration: none; } .main-navigation li a {/*re-style all links/ border-bottom: 0; color: #6a6a6a; line-height: 3.692307692; text-transform: uppercase; white-space: nowrap; } .main-navigation li a:hover, .main-navigation li a:focus { /*change text color for hover/ color: #000; } .main-navigation li {/*re-style margins and locations for navigation links/ margin: 0 40px 0 0; margin: 0 2.857142857rem 0 0; position: relative; } .main-navigation li ul {/*re-style sub-headings for hover/ margin: 0; padding: 0; position: absolute; top: 100%; z-index: 1; height: 1px; width: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); } .main-navigation li ul ul {/*re-style sub-sub-headings for hover/ top: 0; left: 100%; } .main-navigation ul li:hover > ul, .main-navigation ul li:focus > ul, .main-navigation .focus > ul {/*display settings for hover elements/ border-left: 0; clip: inherit; overflow: inherit; height: inherit; width: inherit; } .main-navigation li ul li a {/*re-style sub-heading elements for normal screens/ background: #efefef; border-bottom: 1px solid #ededed; display: block; font-size: 11px; font-size: 0.785714286rem; line-height: 2.181818182; padding: 8px 10px; padding: 0.571428571rem 0.714285714rem; width: 180px; width: 12.85714286rem; white-space: normal; } .main-navigation li ul li a:hover, .main-navigation li ul li a:focus {/*re-style hover colors for sub menu items/ background: #e3e3e3;/*—example of more selective elements to override/ color: #444; } .main-navigation .current-menu-item > a, .main-navigation .current-menu-ancestor > a, .main-navigation .current_page_item > a, .main-navigation .current_page_ancestor > a {/*display style for primary

color: #636363;/*element link same as for current link /

font-weight: bold;/*so you know which primary link was selected/ } .menu-toggle { /*turn off the menu button for normal screens/ display: none; }



I hope this article helps you code better CSS.

Share this post

Link to post
Share on other sites

.... Mayo long... I might come back to it.

Share this post

Link to post
Share on other sites

You know, I started writing this thinking you needed help!! I got to the part where you said "it was still kind of fuzzy to you". I apologize!! Yet, I decided to continue on and post this. It took me a while to write! so I am posting it!! lol


I too hope this helps Someone!! Anyone!!



First, let me say this: KEEP IT SIMPLE!!!!



CSS Syntax selector { css-property: value; css-property: value;} You can group Selectors using a combinator, such as a comma which means "AND". An empty space means something all together different!! It implies descendancy. Check out this Video: YOUTUBE (See attached infographic) Okay, let's move along.

All code is executed sequentially. This means that if you declare a style higher up on the page, then you can undeclare it lower down. It also means that you can declare different styles in a top-down approach of increasingly narrower specificity. For instance, begin at the top and select all Object types for the most general style. Then select a subset of those types to single out for a different style. Continue to the most specific selector last.

Executed...... sequentially.... Not so sure I would say it that way. But, the web browser has a mechanism called the "Cascade". The Cascade is meant to decide which Style will be applied should there be conflict.. .... Conflict among Styles means there is more than one Style that targets the same element and has the same Media Type. Instead of the word Executed, the W3C CSS2.1 specs say,"Once a user agent has parsed a document and constructed a document tree, it must assign, for every element in the tree, a value to every property that applies to the target media type." (go to http://www.w3.org/TR/CSS2/cascade.html to read all about the Cascade.) What you are actually referring to is the Cascade of Styles. But, instead of "undeclaring a style", we can Override a Style. Yes, the order in which the Styles are specified on the External Style Sheet (or any type of style sheet) plays a role in determining which styles get applied, assuming there is conflict (or you are trying to override a style). But there are other factors that determine how the Styles Cascade, and which get applied should there be conflict. (Inline Styles override Internal & External Styles; Specificity: the most specific Selector will usually win; As will !important declarations. Author Styles usually override Browser Styles, etc) Object Types... this is not quite the correct terminology. I think you really mean to say Elements or Tags. (You must be a coder using the DOM!) And it is true, we typically specify more general styles initially, and later on override those styles with increasing Specificity.... to some degree. EXAMPLEFor instance, CSS Inheritance can really save a lot of time when writing CSS. Inheritance is another factor that plays into the Cascade of Styles. A perfect example is styling the <body> of the web page.......................... To do this, we use a Tag or Element Selector, which is General to some extent. body { font-family: Arial, Helvetica, sans-serif; } The CSS Property, font-family, is a property that can be inherited from Parent Elements, or Ancestors in the Document Tree. CSS Inheritance is the process in which certain CSS Properties can be passed down from Parent to Child, or Ancestor to Descendant. Thus, by setting the font-family on the body style, EVERY ELEMENT on the Page will Inherit that font-family. Soooo.... we only need to specify that font-family one time via the body style, UNLESS we want to override that font-family as we likely would when styling heading tags. Thus, my next style would be the following........ h1, h2, h3, h4, h5, h6 { font-family: Oswald, sans-serif;} This style is still quite general, but it will override the font-family that is passed down from the body, causing all heading tags to have Oswald as their font. Once we get the Layout made, we can make our Heading Styles much more specific thereby style h2 headings in different parts of the layout uniquely if we so desired. Each section of the Layout can be given an id, which we would style with an ID Selector. For instance, <div id="header"> </div> or <header id="header"> </header> #header { height: 100px;} Notice how the ID selector matches the id attribute. That is how we hook some css styles to the html markup. Now let's assume you have an h1 Heading for your onpage title, and an h2 Heading for the Tagline. We would get very specific and use the following Selectors........ #header h1 { ... }#header h2 { ... } Then, the h2 Headings in the #main-content section of the web page can be styled using the following Selector: #main-content h2 { ... } SELECTORSRemember to avoid the term "Objects". They are elements in the document tree. (The DOM is where Objects come into play.)**And there are MANY MANY different types of Selectors but Beginners need to first learn the basic ones:

  • [*]ID selectors[*]Class selectors[*]Tag or Element Selectors[*]Dynamic Pseudo Class Selectors (a:link, a:visited, a:hover, a:active, a:focus)[*]Descendant Selectors (
#header h2 is a descendant selector - meaning we are styling nested elements.)



.class1 .class2 .class3 object

(this part is a little fuzzy because sometimes you need the ancestors, and other times you don't)


Okay, there are times when you will use a Class selector without an Ancestor.

***Remember, class selectors can be applied to a given web page numerous times. ID selectors, on the other hand, must be unique and can be applied only one time on a given page.


Therefore, you will find times when you need to create a class for the purpose of applying it to a portion of an html element. This does not require the ancestor in the selector.


Perfect Example: I often create various styles to apply to some text or a few words in my paragraphs.


.bold-red {

font-weight: bold;

color: #ff0000;



This style can be applied over and over again on the same page, and it is Independent of any Ancestor. And.... I often apply that class to a portion of an html element, not the entire element.


<p>Lorem ipsum dolor sit amet, <span class="bold-red">consectetur adipiscing elit</span>. Nunc sit amet porttitor nibh. Ut mattis rutrum enim, sed fringilla metus semper nec.</p>



Another Class I like to create and use a lot:


.center {




I don't like to center all of my text. That looks aweful. However, from time to time, I do like to center the text within a particular paragraph. In that case, the class .center must be applied to the <p> element and NOT to the text in that <p> element.


<p class="center"></p> will cause the text in this p tag to text-align center.


You can read more about Using Class Selectors.


phew... I need a nap now!!


Best wishes to all CSS Authors out there! And Aspiring Authors!!


  • Like 1

Share this post

Link to post
Share on other sites

Keep it as complex as possible. Or other will steal your ideal! :-) happy coding!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now