Custom css but only on specified areas of page or lines

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
bulgin
Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Sun Sep 30, 2007 10:18 pm

Custom css but only on specified areas of page or lines

Postby bulgin » Sun Mar 19, 2017 12:05 am

Hello.

I know there is a simple solution to this. I have a client who specifically wants to change the line spacing of only certain paragraphs/lines on a page.

The custom.css applies to existing known h2, h3, h1, p, br etc. and making changes here applies to *all* paragraphs with h2, h3, p, etc. across the site.

But I only need to apply a custom line-height in selected areas on pages, and would prefer to be able to make this so I can see it in the fckeditor pull down window for styles or headings so it's would be easy to apply.

Any help much appreciated.

Thanks!

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 22669
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: Custom css but only on specified areas of page or lines

Postby Per Yngve Berg » Sun Mar 19, 2017 10:52 am

Use a more restrictive selector, i.e. a class name.

Code: Select all

h2.special {...}
div.special h2 {....}


https://www.w3schools.com/cssref/css_selectors.asp

bulgin
Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Sun Sep 30, 2007 10:18 pm

Re: Custom css but only on specified areas of page or lines

Postby bulgin » Sun Mar 19, 2017 2:18 pm

Ok. Great. Thank you, this is a good start.

In my custom.css I have placed the code:

h2.special {
line-height:3.00em;
}

but it neither shows up under the JCE editor pull down window under styles or format, nor can be hard-coded into the code editor.

What am I doing wrong?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 22669
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: Custom css but only on specified areas of page or lines

Postby Per Yngve Berg » Sun Mar 19, 2017 3:06 pm

Have you specified custom.css as the editor content css file in Global Configuration of the JCE Editor?

bulgin
Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Sun Sep 30, 2007 10:18 pm

Re: Custom css but only on specified areas of page or lines

Postby bulgin » Sun Mar 19, 2017 7:42 pm

Okay. I will do that but a question first: if I specify custom.css then I assume only the entries in custom.css will apply in JCE editor - thereby losing many of the other classes in template.css.

So is it better than to place the code in template.css so that I won't lose the classes int template.css ?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 22669
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: Custom css but only on specified areas of page or lines

Postby Per Yngve Berg » Sun Mar 19, 2017 7:52 pm

It only affects what is shown in the drop-down. You can make a file with the classes that shall show in the drop-down. The css files are loaded in the template and what is shown on the site is not affected.

bulgin
Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Sun Sep 30, 2007 10:18 pm

Re: Custom css but only on specified areas of page or lines

Postby bulgin » Mon Mar 20, 2017 1:55 am

Great! Thanks for explaining all that. You are a life-saver!


Return to “Templates for Joomla! 3.x”

Who is online

Users browsing this forum: No registered users and 4 guests