I'm trying to get conditional CSS to work in Blogger / Blogspot - might be missing something obvious and fundamental to make it work but here we go.
A number of tutorials I've found have provided instructions but when i follow them they don't work (nb: they work perfectly when used in the template body to hide certain widgets on certain pages but i can't get them to work to style different elements differently on different pages).
So, as an example I want to have a different date background color depending on what page you're on here.
The date header styling is:
.date-header span {
background-color: #FF8BBF;
color: $(date.header.color);
padding: $(date.header.padding);
letter-spacing: $(date.header.letterspacing);
margin: $(date.header.margin);
}
I want the background color of the date to be different on another page, so as per various tutorials I've added the following code just above the template closing head tag.
<b:if cond='data:blog.url == "http://mgmmediaadditionaldemoblog.blogspot.com.au/search/label/Test2"'>
<style>
.date-header span {
background-color: #FF937E;
}
</style>
</b:if>
But it's not changing the colour on the page specified. I've tried variations - putting the conditional code in the b:skin or b:template-skin sections of the head but i can't make it work - any help on this would be greatly appreciated!
try this code:
<b:if cond='data:blog.searchLabel == "Test2"'>
<style>
.date-header span {
background-color: #FF937E!important;
}
</style>
</b:if>
Test2 is the label, and add !important to your color code to make browser load background-color: #FF937E instead of background-color: #FF8BBF;.
I wait for your feedback :)
Related
I am completely new to this and am trying to learn on my own. One thing I am having an issue on finding a solution to is how to hide the page title on a WP site. I have read that leaving the page title blank, although solving the issue, may not be good in terms of SEO, so I would like to hide page titles instead.
I have tried using multiple plugins, all with no luck. Additionally, I have tried adding additional CSS code both to hide specific page titles and titles across the entire site.
The code I have been using is
.entry-title {
display: none;
}
and
.page-id-XXX .entry-title {
display: none;
}
None seem to work. Additionally, I tried to see if my theme has an option, and it doesn't.
Is anyone able to let me know what I may be doing wrong and point me in the right direction?
Use the code below to hide header.
.header-page {
display : none;
}
This will work when the header has class .header-page.
This CSS should go inside every page where you want to hide, if its site-wide add it on head.
<style>
.header-page {
display : none;
}
</style>
I'm working on an Unbounce project and I can't get the stylesheets to work.
I wanted to change the font-size of the labels of an option on the form. I saw (using inspect element) that the following CSS created affects the size: #lp-pom-form-55 .lp-pom-form-field .option label
So I created a stylesheet in Unbounce like this:
<style>
#lp-pom-form-55 .lp-pom-form-field .option label {
font-size: 16px !important;
}
</style>
And it just doesn't work. I also tried it without the style tag like this:
#lp-pom-form-55 .lp-pom-form-field .option label {
font-size: 16px !important;
}
It still didn't work. I even tried basic things like setting the background color of normal text field id's to black !important with no solution.
What is the correct way to apply styles to Unbounce pages?
I've realized that the code within the <style> tags is the correct way to do it. The problem was that the custom CSS doesn't display in the designer view, it only shows on the live page.
I'm designing a site using a simple worpress theme and customising a few elements with the Simple Custom CSS plugin.
I'm trying to change the colour of the footer and I've used
.site-footer {
background: #4E5754;
color: #f29e0f;
}
This is coming though as it is changing the text colour but not the background - the new background colour is showing up when I inspect the page source but not changing on the actual page.
What might be overriding the CSS?
You can use this style for this.
.site-footer {
background: #4E5754 !important;
color: #f29e0f;
}
Or put your style under the default stylesheet.
After a bit of trial and error I realised that the two colours were actually being controlled by different elements - site.footer and footer.inner
Thanks for the help everyone!
I'm trying to get a different background color for each different main content block on the pages on this website: http://www.amachielsenadvies.nl .
So far I have found out that this line in css can control the background color:
.sidebarwidth .box.one { background-color: #f8dffc;}
but I want a different color on different pages. A page ID i have found is 18 (or post ID), but it is unclear what has to be added in css to accomplish
Can anyone help me with that?
Each page can be uniquely identified through the page-id-* class on the body.
So to change the background color on the home page, e.g.
.page-id-45 .sidebarwidth .box.one { background-color: #f8dffc;}
If the page has an ID of 18...perhaps ID="post-18" I would assume that this has been applied to the body
<body ID="post-18">
then the CSS would be
#post-18 .sidebarwidth .box.one { background-color: #f8dffc;}
Just use the body classes
example
body.page-id-18 .sidebarwidth .box.one { background-color: #f8dffc;}
I copied CSS code for bs-example from the Bootstrap 3.0.3 docs site. I'm kind of a beginner with CSS, so if anyone could explain me this I would be thankful.
The following code:
/* Echo out a label for the example */
.bs-example:after {
content: "Example";
position: absolute;
top: 15px;
left: 15px;
font-size: 12px;
font-weight: bold;
color: #bbb;
text-transform: uppercase;
letter-spacing: 1px;
}
It works as expected,
but I would like the title, EXAMPLE, can be changeable. I would like to use a tag like let's say <zd></zd>.
Thanks in advance.
Prior to writing this answer, I didn't realise that editing Pseudo Elements (::after) with JavaScript was a little trickier. Although with this question/answer on StackOverflow made it relatively easy with JavaScript.
The concept was still the same, upon Page load the browser renders what is stated on the Style sheet, there after you must use JavaScript to manipulate it's contents to render something different.
Hence the CSS looks at the attr(data-content), which means it'll look for the data-content attribute within the HTML.
.bs-docs-example::after {
content: attr(data-content);
}
This looks for the data-content="":
<div class="bs-docs-example" data-content="Example Header">
Which renders:
To change it there after, all you have to do is change it's data-content attribute with JavaScript, in the demo I use jQuery to quickly select the DOM element and adjust it's data-content attribute.
$('.bs-docs-example').attr('data-content', "New Header Title" );
Demo Fiddle: http://jsfiddle.net/u2D4M/
If you wanted to do this without jQuery:
<script>
var getHeader = document.getElementById('bs-header');
getHeader.attributes["data-content"].value = "Hi, New Title";
</script>
Demo Fiddle: http://jsfiddle.net/9wxwxd4s/
The :after selector Insert content after every .bs-example class.
Here, the Word Example will be added after every .bs-example.
[please refer this link]http://www.w3schools.com/cssref/sel_after.asp
Instead of using content:"Example", you can edit your titles in html and assign the same class to all titles. header tags are preferred. ie., You should definitely create a new custom stylsheet and override the classes you want to modify. This is a way you can always go back to the default styling provide by bootstrap.
This is a simple and easy step followed by all web developers as per W3C std.
Still you want to change title by code, you can get help from jQuery or JS.
Tip from Christofer Eliasson: If you want to redesign your page, you can just exchange your custom stylesheet with a new one. Instead of getting a completely new bootstrap file to be able to start over. Also, if you just want to go back to the default styling on just a few elements, it would be a mess to remember what changes you have made. So, write your custom css code in a separate stylesheet.