ElkArte Community

Elk Development => Theme development => Topic started by: TE on January 30, 2014, 11:29:58 am

Title: Elk styling made simple
Post by: TE on January 30, 2014, 11:29:58 am
Just to show you the capabilities of our templates and CSS.. Here are some examples for styling the board index.

1) changing a single category's color, im my example it's the category with ID 6.
Code: [Select]
#category_6 h2 {
color: white;
background-color: #666;
text-shadow: none;
}
#category_6 h2 a {
color: white;
background-color: #666;
text-shadow: none;
}
2) making the boards inside the category zebra striping
Code: [Select]
#category_6 .board_row:nth-child(odd) {
background-color: #f8f8f8;
}
#category_6 .board_row:nth-child(even) {
background-color: #f1f1f1;
}

3) adding some fancy board icons,
We need to hide the old ones first,  I've used my boards with ID 29, 19 and 111.
Code: [Select]
#board_23 .board_icon, #board_29 .board_icon, #board_19 .board_icon, #board_111 .board_icon {
background-image: none;
}
Now the original Icons are hidden, let's add some new ones.. I've used the internal font awesome but you can do that with images, too.
The complete icon list from FontAwesone is here: http://fortawesome.github.io/Font-Awesome/cheatsheet/
Code: [Select]
#board_29 .board_icon:before {
font-family: "FontAwesome";
content: '\f0a5';
position: relative;
top: 5px;
font-size: 2.7em;
color: #666;
text-shadow: 1px 1px 2px #555;
}
#board_19 .board_icon:before {
font-family: "FontAwesome";
content: '\f108';
position: relative;
top: 5px;
font-size: 2.7em;
opacity: 0.8;
color: green;
text-shadow: 1px 1px 2px #555;
}

#board_111 .board_icon:before {
font-family: "FontAwesome";
content: '\f001';
position: relative;
top: 5px;
font-size: 2.7em;
opacity: 0.8;
color: darkred;
text-shadow: 1px 1px 2px #555;
}
4) Now we give the related boards another link color:
Code: [Select]
#board_111 a {
color: darkred;
}
#board_23 a {
color: GoldenRod;
}
#board_19 a {
color: green;
}
This is our result ;) Quite simple, right?
Title: Re: Elk styling made simple
Post by: Jorin on January 30, 2014, 01:53:17 pm
Simple and effective and so cool!  :)
Title: Re: Elk styling made simple
Post by: Nao on January 30, 2014, 02:57:43 pm
Is this not already possible with SMF..?

Candid question. Where would you out that CSS? Because modifying a stock file makes it impossible to upgrade later...
Title: Re: Elk styling made simple
Post by: TE on January 30, 2014, 03:13:46 pm
Quote from: Nao – Is this not already possible with SMF..?
yes, I think so but the SMF BoardIndex is based on tables with images for on, on2, redirect and off status. The CSS would be completely different ...

Quote from: Nao – Candid question.Where would you out that CSS? Because modifying a stock file makes it impossible to upgrade later...
It's currently one of the normal CSS files but I'm thinking about adding a "custom.css" for a long, long time (made a first suggestion for this in 2009 while working on Curve), just throw that file in the related folder and it's automatically loaded.

Title: Re: Elk styling made simple
Post by: emanuele on January 30, 2014, 03:28:40 pm
Quote from: Nao – Is this not already possible with SMF..?
Not unless you don't care about read/unread status.

Quote from: TE – It's currently one of the normal CSS files but I'm thinking about adding a "custom.css" for a long, long time (made a first suggestion for this in 2009 while working on Curve), just throw that file in the related folder and it's automatically loaded.
I'd vote for a db record in {db_prefix}settings: no need to worry about writable state of the file, no need to mess with chmod, the entire Be Social! variant is less than 30k chars, so anything custom should fit into a TEXT column (heck if you need more than a variant just write a theme :P).
Title: Re: Elk styling made simple
Post by: Nao on January 30, 2014, 04:33:22 pm
Quote from: TE – It's currently one of the normal CSS files but I'm thinking about adding a "custom.css" for a long, long time (made a first suggestion for this in 2009 while working on Curve), just throw that file in the related folder and it's automatically loaded.
That's how I did it in Wedge (and it's working pretty well). Ema's suggestion is something I considered, too, but ultimately went against because modifying CSS through the admin area represents a 'break' in the workflow. You have to open the main CSS in a file, and then use your browser to add your changes.
Plus, having a custom.css file anywhere you want gives you more freedom than, for instance, switching to a different skin/theme in the admin area, editing the file for it, then switching to another theme, etc. Complicated, if you ask me...
Title: Re: Elk styling made simple
Post by: TE on January 31, 2014, 12:45:13 am
Problem I see with a database entry is: If you want it differently for the installed themes / variants you'd need to store it per theme + variant.. We'd need an UI for that.
Title: Re: Elk styling made simple
Post by: Nao on January 31, 2014, 03:48:22 am
The only advantage I can see to the DB version is that it skips a file_exists altogether (unless you don't do realtime checks on file changes..?), because obviously Elk is made 'aware' of any changes right when you submit them... ^^
Title: Re: Elk styling made simple
Post by: Allan on February 18, 2014, 09:37:32 am
As a novice theme maker I really like how you can do this in css and without mods. Great post.
Title: Re: Elk styling made simple
Post by: Antechinus on February 25, 2014, 04:58:44 pm
You should post up the examples for re-ordering the board index components, if they're no longer in the css file (I assumed they would be removed before the thing was ready for production).

ETA: The custom highlighting colour is a bit nasty IMO. It's one of those acidic sort of greens that is more putrid than green.
Title: Re: Elk styling made simple
Post by: radu81 on January 31, 2015, 08:29:01 am
very nice, I was going to ask this ;) Thanks TE!
Title: Re: Elk styling made simple
Post by: radu81 on February 01, 2015, 10:40:28 am
I'm having some problems using this trick on IE, the icons are huge and also on mobile. I don't know what I am missing.

my css file: skodaclub.it/themes/default/css/_besocial/custom_besocial.css

On chrome and firefox it eorks fine. Thank you in advance
Title: Re: Elk styling made simple
Post by: TE on February 01, 2015, 10:43:24 pm
I'd remove the font-size: 2.7em; from all custom board icons.

so instead of
Code: [Select]
#board_28 .on_board:before {
font-family: "FontAwesome";
content: '\f0f4';
position: relative;
top: 5px;
font-size: 2.7em;
color: #4ba82e;
}
use
Code: [Select]
#board_28 .on_board:before {
font-family: "FontAwesome";
content: '\f0f4';
position: relative;
top: 5px;
color: #4ba82e;
}
the font-size is already set (and also reduced) a few lines before.
Code: [Select]
.off_board:before, .new_none_board:before {
font-family: "FontAwesome";
content: '\f0e6';
position: relative;
top: 5px;
font-size: 2.7em;
color: #aaa;
}
Title: Re: Elk styling made simple
Post by: radu81 on February 02, 2015, 02:51:42 am
Thanks TE, that worked.

Just a little problem, only on IE, the icons above the Info Center are still big
Title: Re: Elk styling made simple
Post by: TE on February 02, 2015, 03:17:42 am
Try adding this to your custom css file..
Code: [Select]
.new_redirect_board:before, .new_none_board:before, .new_some_board:before {
font-size: 1.2em;
position: relative;
top: -2px;
}
Title: Re: Elk styling made simple
Post by: radu81 on February 02, 2015, 03:51:05 am
that didn't solved the big icons on IE above Info center
Title: Re: Elk styling made simple
Post by: TE on February 02, 2015, 10:57:00 am
Which Version of IE is it?
Title: Re: Elk styling made simple
Post by: radu81 on February 02, 2015, 11:57:52 am
IE 11 win7, and also on win8
Title: Re: Elk styling made simple
Post by: TE on February 02, 2015, 10:41:23 pm
ok, can you try
Code: [Select]
.new_redirect_board:before, .new_none_board:before, .new_some_board:before {
font-size: 15px !important;
position: relative;
top: -2px;
}
IE seems to be a bit stupid regarding em somethimes. this version uses px for the font size instead.
Title: Re: Elk styling made simple
Post by: radu81 on February 03, 2015, 05:02:20 am
Thanks for your help @TE , is working fine now  ;)
Title: Re: Elk styling made simple
Post by: blueone on June 15, 2015, 02:28:28 am
Morning,

i tried the changes form the first post.

Link Color and category color but nothing happend.

i changed the id to my forum, so i was wondering if there was a elkarte general change?

quelltext show me this

<div class="forum_category" id="category_3">
and
<li class="board_row" id="board_34">
for example
Title: Re: Elk styling made simple
Post by: TE on June 15, 2015, 06:53:30 am
This should change the background color / link color from category_3.
Code: [Select]
#category_3 h2 {
color: white;
background-color: #666;
text-shadow: none;
}
In which file did did you place that code? Have you cleared the forum cache / browser cache? Maybe it's just a caching issue..

A link to your forum would be helpful..
Title: Re: Elk styling made simple
Post by: blueone on June 15, 2015, 07:25:47 am
now it works... ;) dont know why i cleared the chache before, it was also my first idea,

but now it works so never mind :)

Thank you

edit:

i was wondering if it possible to style the inside of the board the same as at the front?
i mean when i give a board a color like red then the inside posts should also be red...

but so far i see there is only a way to style all boards the same inside ore i wrong?
Title: Re: Elk styling made simple
Post by: CrimeS on June 15, 2015, 07:43:31 am
Can we grab the number of categories and store it into the variable? I would like to make "intelligent" system that will generate random, or with pattern type coloured categories.
Title: Re: Elk styling made simple
Post by: blueone on June 15, 2015, 07:47:41 am
@CrimeS that would be nice! and i think that should be possible the ID is stored in the database... but i am to new to elkarte to figure out how it works exactly
Title: Re: Elk styling made simple
Post by: TE on June 16, 2015, 10:58:55 pm
Quote from: blueone – i was wondering if it possible to style the inside of the board the same as at the front?
i mean when i give a board a color like red then the inside posts should also be red...
OK, not sure I understand right.. You wan't to colorize the boards not just on the board index but on the message index / posts display too?

There's a class="action_messageindex board_X" attached to the html body tag, so in theory it should be possible to style it via this attribute.
Title: Re: Elk styling made simple
Post by: blueone on June 17, 2015, 02:45:49 am
yea TE you get me right i made some pictures to make it realy clear...

so far the cebra styling inside "board index" works with "basic_row" that was easy because i want that for all boards :)
but the link color mean the "h4 tags" inside board index is a diffrent story but i will try to figure it out my self ;)

on a first try it seam it dosent works so easy but i will try it again later the day...

is there somwhere a collection or doku about the tags and so on?

thx TE

Title: Re: Elk styling made simple
Post by: blueone on June 22, 2015, 05:26:18 am
TE can you please give me a example with the "action_messageindex board_X" and styling the board index!?

i have tried serveral diffrent things but i think im on the wrong way...

thank you
Title: Re: Elk styling made simple
Post by: emanuele on June 22, 2015, 07:20:05 am
You may use for example:
Code: [Select]
#action_messageindex board_1 #description_board .category_header {
    color: red;
}
for the board title (Allgemein in your second picture), or:
Code: [Select]
#action_messageindex board_1 .category_header {
    color: red;
}
to color anything using category_header in that page.

For the topic titles you can use:
Code: [Select]
#action_messageindex board_1 .topic_name {
    color: red;
}

then, for the topic subject inside the topic itself (picture 3) you can use:
Code: [Select]
#action_messageindex board_1 #forumposts .category_header {
    color: red;
}
or otherwise the more general one:
Code: [Select]
#action_messageindex board_1 category_header {
    color: red;
}
that is the same as the previous for board titles. ;)

and for the reply numbers:
Code: [Select]
#action_messageindex board_1 .postarea .keyinfo {
    color: red;
}

Of course than you can change the "1" after the id of the board to selectively apply different color schemes to different boards. ;)
Title: Re: Elk styling made simple
Post by: blueone on June 22, 2015, 07:33:01 am
ah im so an idot...

the # and so makes the vodoo ;) i had nerly the same but there where missing some arguments...
thanks TE for your hard work!!!!!
Title: Re: Elk styling made simple
Post by: emanuele on June 22, 2015, 09:45:33 am
lol
I know the feeling about CSS! ;D
Title: Re: Elk styling made simple
Post by: blueone on June 22, 2015, 10:54:45 am
Quote from: emanuele – lol
I know the feeling about CSS! ;D

yeah css gets me evrytime dont know why ;) maybe i should let it go^^

so back to topic the topic links are not working as i want...

i see with firebug this when i watch the "topic name link"

.topic_name h4 a {
    color: #43a8da;
}
.topic_name h4 a {
    font-weight: bold;
}
a, a:link, a:visited, a.new_win:link, a.new_win:visited {
    color: #008299;
    text-decoration: none;
}
a, a:link, a:visited, a.new_win:link, a.new_win:visited {
    color: #008299;
    text-decoration: none;

i use the Be Social  standart theme to work with...
as i see there are active classes for the "topic name" part... maybe some of this holds me on?

i tried so far to change that in the coustom.css and in the be social custom.css but it dosent works...
i have tried to change the color of the ".topic name" for all boards generaly that works.



Title: Re: Elk styling made simple
Post by: br360 on July 02, 2015, 02:05:33 am
Thanks for the tip; it worked great using the font awesome icons. (see attached image)

Any way to be able to add other types of icon images though? I tried uploading images to my directory and nothing. Here is the code I was trying to use if it helps (basically just added the image path to the code you already provided)-

Code: [Select]
#board_4 .board_icon:before {
   background-image: url(../../images/_besocial/newicon.png);
   position: relative;
   top: 5px;
   font-size: 2.7em;
   opacity: 0.8;
   text-shadow: 1px 1px 2px #555;
}
Title: Re: Elk styling made simple
Post by: TE on July 02, 2015, 02:01:58 pm
Hir br360 and welcome to ElkArte..

I feel the path to the background image is wrong.. it's currently
Code: [Select]
background-image: url(../../images/_besocial/newicon.png);
but it should be
Code: [Select]
background-image: url(../images/_besocial/newicon.png);
Title: Re: Elk styling made simple
Post by: br360 on July 02, 2015, 03:40:50 pm
Thanks @TE - tried that code but it didn't work either. Still shows blank where the icon should be. Pretty sure the path is correct and the image is in the right folder; just not sure what I'm doing wrong.

Thank you though.
Title: Re: Elk styling made simple
Post by: TE on July 02, 2015, 11:40:23 pm
is your newicon.png a single image or a sprite with all states?

something like this should work should work for a single image, reagarding the status (on, on2, off)
Code: [Select]
#board_2 .board_icon {
   background: url('../../images/_besocial/newicon.png') no-repeat;
}
Title: Re: Elk styling made simple
Post by: br360 on July 03, 2015, 01:02:22 am
It was just a single image; and that code worked great @TE , thank you.  :)
Title: Re: Elk styling made simple
Post by: Jorin on September 02, 2015, 02:47:22 am
I tried to colorize the board names as @TE described in the very first post of this thread. It works fine. But it only works with board titles, not with subboard titles and thread titles.

Is there a way to colorize all titles (board, subboards, threads) inside a category?
Title: Re: Elk styling made simple
Post by: emanuele on September 02, 2015, 07:57:06 am
Code: [Select]
#category_6 {
color: white;
background-color: #666;
text-shadow: none;
}
Title: Re: Elk styling made simple
Post by: Jorin on September 03, 2015, 07:08:53 am
That changes not the text, only the small space between the boards.
Title: Re: Elk styling made simple
Post by: wintstar on September 03, 2015, 08:37:14 am
@Jorin look here. With the addon Firebug for Firefox i find just about everything in a Theme. Is a good tool for Theme Designer.

https://www.youtube.com/watch?v=D626ytfJryI
Title: Re: Elk styling made simple
Post by: Jorin on September 03, 2015, 08:55:06 am
I know such tools, but they don't help in this case.  ;)
Title: Re: Elk styling made simple
Post by: wintstar on September 03, 2015, 09:18:20 am
Style ElkArte Default light
board
.../themes/default/css/_light/index_light.css
Code: [Select]
.board_name > a {
    color: #377828;
}

subboards
text
Code: [Select]
.childboard_row h4, .board_new_posts {
    font-weight: 700;
    color: #777;
}

link (title)
Code: [Select]
a, a:link, a:visited,
/* Links that open in a new window. */
a.new_win:link, a.new_win:visited {
    color: #49643d;
    text-decoration: none;
}

threads
Code: [Select]
.topic_name h4 a {
    color: #4b863c;
}

Title: Re: Elk styling made simple
Post by: badmonkey on September 22, 2015, 10:04:37 pm
This is all fantastic information!  Thanks everyone!