Thymeleaf: how to use conditionals to add/remove dynamically a CSS class
Tags: html,css,thymeleaf
Problem :
By using Thymeleaf as template engine, is it possible to add/remove dynamically a CSS class to/from a simple div
with the th:if
clause?
Normally, I could use the conditional clause as follows:
<a href="lorem-ipsum.html" th:if="${condition}">Lorem Ipsum</a>
We will be creating a link to the lorem ipsum page, but only if condition clause is true.
I'm looking for something different: I'd a block always visible, but with changeable classes according to the situation.
Solution :
There is also th:classappend
.
<a href="" class="baseclass" th:classappend="${isAdmin} ? adminclass : userclass"></a>
If isAdmin
is true
, then this will result in:
<a href="" class="baseclass adminclass"></a>
CSS Howto..
Sadly to due various versions and browsers types across the globe there is not a single CSS entry that is compatible on all browsers without JavaScript intervention. You can however...
Yes there is a pure CSS3 way to do this. The property you need is pointer-events Adding nav ul { pointer-events:none; } nav:hover ul { pointer-events:auto; } seems to fix...
this may help you <div class="tricky"><img class="tricky_image" src="http://distilleryimage11.instagram.com/65c8f832841711e180d51231380fcd7e_7.jpg"></div> css part: .tricky { display:inline-block; max-width:200px; max-height:200px; background:red; } .tricky_image { max-width:200px; max-height:200px;...
For the root svg you can simply use regular CSS styling, as opposed to stroke etc: Demo Fiddle Change svg{ stroke:blue; stroke-width:20px; } To svg{ border:20px solid blue; } ...
The page you linked does not show the login for anyone who is already logged into GitHub, so you may want to be a little more specific next time or...
#tabs { border-bottom:#2763a5 1px solid; font-size:93%; line-height:normal; width:100%; text-align:center; } #tabs ul { display:inline-block; display: -moz-inline-stack; // Firefox 2 doesn't understand inline-block but this acts the same zoom: 1; //...
The idea is called CSS Sprites. Search on that, but basically your intuition about how/why it works is correct! See this SO: css icon images or icon image? jQuery UI...
YES, That condition might work for you, but only if placed on the right place. if ( in_category( 'Quotes' ) || post_is_in_descendant_category( id_of_Quotes_category ) ) When ever a post is...
You need to add width in both span and use max-width intend of width of image eventPic class named. .section_header { background-color: gray; width:100%; height:5em; display: table; } .section_header span...
It's not possible with CSS only.
//same place when scrolling: position:fixed; //just stay at the top position:absolute; top: 5px; left: 5px; Note: for absolute, make sure it is not inside an element with position:relative; or just...
To spread the childs horizontally, we use display: table-cell and to spread the childs vertically, we can use display: table-row. But display: table-row needs some content in it, which I...
There is so much you can learn from just inspecting using the developers tools from Firefox or Chrome... and this is just what I took from that website: http://codepen.io/anon/pen/BjoWYe the...
HTML: <div id="slideshow"> <img src="http://docode.com.ua/wp-content/uploads/pictures/pic-3.jpg"/> <img src="http://docode.com.ua/wp-content/uploads/pictures/pic-2.jpg"/> <img src="http://docode.com.ua/wp-content/uploads/pictures/pic-1.jpg"/> </div> CSS: #slideshow { width:100%;...
I have used percentages to the input fields. The 'last name' field have a border so it was needed to set it as box-sizing: border-box: otherwise it would fall down...
So... how to solve this problem... It was not that easy but with the help of the w3c and your answers I was able to get to a proper result....
if you're using jquery, you can just do $('#test').css('display','none'); That will hide the element and leave the background untouched. [Edit] I don't think I understood the question before. Per your...
I was able to add this jquery in order to add a scroll and it worked great: <script class="code" language="javascript" type="text/javascript"> $(document).ready(function () { var window_width = $(window).width() - 280;...
This page has some examples for styling on common devices using CSS media queries Edit: A small tip on how to emulate devices for testing in Chrome (This has saved...
Add a class on click before showing the div which sets display to table. I have made a JSFiddle. Please check here if it fits your requirements Click handler changes...
Why dont you just use the same width for the buttons? .button{ width:193px; //More Styles here ... } Or do some math if you want blank space .button{ width:188px; margin-right:5px...
Having struggled with the issue in a recent large-scale project myself, I applaud you to bringing this to attention on SO. I'm afraid that there's not a single 'correct' solution...
By placing your ball/circle image inside a container div and rotating that div, you can create the illusion of the ball traveling around the background. You will have to play...
Firefox doesn't support it. There's a work-around for Firefox 3.x, but that also doesn't work in FF4. I'm told that they plan to add support in FF6. As of this...
A lot of the really "artsy" sites are produced in another program first, usually Adobe Photoshop or Adobe Illustrator, and then 'sliced' into HTML div's. NetTuts has a handful of...
That is why you should not change individual CSS properties from your jQuery/Javascript code. Other than not being elegant, readable and maintainable and not separating presentation from behaviour, it will...
Change display for .my-wrapper to inline-block. This will get rid of its ability to stretch the entire width of its container. Then float it to the right: .my-wrapper { border:...
(function($) { $.get('/css/foobar/tooltips.css', function(data) { var style = document.createElement('style'), head = document.getElementsByTagName('head')[0] || document.documentElemen; style.type = "text/css"; style.textContent = style.text = data; head.appendChild(style, head.firstChild); }); }(jQuery)); The above code would...
The fastest and most trouble-free solution was the analysis of http requests to the server and send the required data.
Maybe take a look at https://github.com/mrclay/minify, while it includes a wrapper for the YUI compressor (which itself is a java command line tool) it's also a standalone PHP library. http://code.google.com/p/minify/wiki/UserGuide...