Hack Forums
Allow my users to switch between set css styles (themes) on my bootstrap site? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: Allow my users to switch between set css styles (themes) on my bootstrap site? (/showthread.php?tid=5546697)

Pages: Pages 1 2


Allow my users to switch between set css styles (themes) on my bootstrap site? - Bluffer - Feb 8, 2017

Hello I am wondering what the best way to allow my users to switch between different style sheets is.

Basically I want to allow a couple different color schemes and style changes and let the user choose which one they want to display and they can save that one as their default.

I don't imagine this is a difficult task so if somebody wants to explain how I could do it that would be awesome!

My site uses Boostrap as I mentioned in the title.


* - slober - Feb 9, 2017

(Feb 8, 2017 05:23 PM)Βluffer Wrote:  Hello I am wondering what the best way to allow my users to switch between different style sheets is.

Basically I want to allow a couple different color schemes and style changes and let the user choose which one they want to display and they can save that one as their default.

I don't imagine this is a difficult task so if somebody wants to explain how I could do it that would be awesome!

My site uses Boostrap as I mentioned in the title.

If I would do this I would first make the different CSS styles or design the different templates

After this you could use a cookie to check which theme (set of styles) he previously used and implement the style the user requested

I would advise using JQuery for this

Here are some tutorials:
  1. http://stackoverflow.com/questions/1599287/create-read-and-erase-cookies-with-jquery

  2. https://www.sitepoint.com/eat-those-cookies-with-jquery/



Possible other techniques (although Jquery would be the most dynamic one) would be:
  1. PHP and cookies

  2. PHP and MySQL





* - Bluffer - Feb 9, 2017

(Feb 9, 2017 06:54 PM)slober Wrote:  If I would do this I would first make the different CSS styles or design the different templates

After this you could use a cookie to check which theme (set of styles) he previously used and implement the style the user requested

I would advise using JQuery for this

Here are some tutorials:
  1. http://stackoverflow.com/questions/1599287/create-read-and-erase-cookies-with-jquery

  2. https://www.sitepoint.com/eat-those-cookies-with-jquery/



Possible other techniques (although Jquery would be the most dynamic one) would be:
  1. PHP and cookies

  2. PHP and MySQL


[Image: wuqnT5V.jpg]

Wow, thank you!


* - SIM-2090815 - Feb 10, 2017

Maybe take a look here http://www.w3schools.com/css/css_intro.asp
They use what your on about here


* - Bluffer - Feb 10, 2017

(Feb 10, 2017 05:54 PM)Dispaced Wrote:  Maybe take a look here http://www.w3schools.com/css/css_intro.asp
They use what your on about here

Thanks for trying but I don't see where I can find the code for that part of the page. Its just an introduction to CSS page which shows that as an example.


* - Bluffer - Feb 17, 2017

Anyone else have some ideas?


* - Bluffer - Feb 19, 2017

Somebody help me plz lol 😁


* - SIM-2908357 - Feb 19, 2017

Slober is correct, you will need JQuery for this.

What the code below does:
- On button click, a function is triggered.
- This function uses JQuery to change your stylesheet.



JQuery is very simple to learn & extremely useful for Front End Design.
If you have any questions please let me know.


* - Bluffer - Feb 19, 2017

(Feb 19, 2017 06:18 PM)Hydroponics Wrote:  Slober is correct, you will need JQuery for this.

What the code below does:
- On button click, a function is triggered.
- This function uses JQuery to change your stylesheet.



JQuery is very simple to learn & extremely useful for Front End Design.
If you have any questions please let me know.

Thanks I'll do my best to follow this.

I recently was doing html/css through FreeCodeCamp just for a refresher but didn't like Jquery when it came to that section I'm sure I'll eventually learn it I just would rather get more experience exclusively in html/css before I move onto that.

Appreciate your help though I'll hopefully be able to implement this into my site.


* - SIM-2908357 - Feb 19, 2017

(Feb 19, 2017 07:25 PM)Βluffer Wrote:  Thanks I'll do my best to follow this.

I recently was doing html/css through FreeCodeCamp just for a refresher but didn't like Jquery when it came to that section I'm sure I'll eventually learn it I just would rather get more experience exclusively in html/css before I move onto that.

Appreciate your help though I'll hopefully be able to implement this into my site.

Btw, instead of starting a project and learning everything you need for it as you go, you should stop and take a week off to read documentations (js, jquery, bootstrap, css, css3, html5).

It helps a ton just reading over documentations, and attempting to understand them.
The way your learning has frequent roadblocks which can be demotivating and discouraging.

I'm not saying you can't learn that way, I just feel that my advice could work for you because it did for me.

JQuery is also extremely essential if you want to go beyond building static un-responsive pages so you need to learn it.


* - grady - Feb 19, 2017

Is this a simple HTML & CSS page or is there anything powering this?


* - Bluffer - Feb 19, 2017

(Feb 19, 2017 07:55 PM)Hydroponics Wrote:  Btw, instead of starting a project and learning everything you need for it as you go, you should stop and take a week off to read documentations (js, jquery, bootstrap, css, css3, html5).

It helps a ton just reading over documentations, and attempting to understand them.
The way your learning has frequent roadblocks which can be demotivating and discouraging.

I'm not saying you can't learn that way, I just feel that my advice could work for you because it did for me.

JQuery is also extremely essential if you want to go beyond building static un-responsive pages so you need to learn it.
Thank you for that, I've been needing some advice like that as I've been finding myself stuck as to where to go next... I feel like the CSS tutorials I've gone through have only taught the main things and not all of CSS as I haven't even learnt about things like FlexBox or web-kit. I'll try reading some documentation but today I've been doing some php on codecademy I would really prefer to work with front-end stuff first though.

(Feb 19, 2017 07:58 PM)๖ۣۜInfamy Wrote:  Is this a simple HTML & CSS page or is there anything powering this?
This website uses Bootstrap.


* - grady - Feb 19, 2017

(Feb 19, 2017 10:44 PM)Βluffer Wrote:  This website uses Bootstrap.

For future reference, Bootstrap is just an HTML, CSS, and JS library.


* - Bluffer - Feb 20, 2017

(Feb 19, 2017 11:08 PM)๖ۣۜInfamy Wrote:  For future reference, Bootstrap is just an HTML, CSS, and JS library.

yes thought that is what you were asking 🎉


* - masterfan - Feb 21, 2017

If you want that change to be permanent (or at least for some time) then you will have to save the change in cookie / localstorage. The thing that "Hydroponics" said works, but once the user refreshes the page he will have the old stylesheet.