Solved

CSS WIld Cards

Posted on 2016-09-26
2
32 Views
Last Modified: 2016-09-26
I need to select a DIV to add a padding-top to and it's id is dynamic.  I know that it will end with _TopNavigationMenu, but the prefix seems random and so I need to have a wildcard to select it in a style sheet.

In this case the searched for string is part of an id.  But in other cases I have to do similar where the searched string is part of a class name.  

In jQuery it would be something like this for the id search: $('div[id$="TopNavigationMenu"]').attr('style','padding-top:10px') .  Again though,  I need to do this in CSS and would appreciate a variation if the value was in a class also.
0
Comment
Question by:hbash
2 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 41816632
There's a similar way of doing it with CSS3 apparently:
div[id$=“_TopNavigationMenu”] {
  padding-top: 10px;
}
div[class$=“_TopNavigationMenu”] {
  padding-top: 10px;
}

Open in new window

0
 
LVL 1

Author Closing Comment

by:hbash
ID: 41816706
Just right.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now