Thymeleaf Page Layouts - html

I am trying use thymeleaf page layouts in my current spring-boot project.
template resources/templates/common/menu.html
<!-- Menu -->
<div id="menu" oncontextmenu='return false' ondragstart='return false' onmousedown='return false'>
<div class="pure-menu">
<a class="pure-menu-heading" href="index.html">
<img src="../../../images/home.png" width="136" height="43" alt="SL" />
</a>
..
</div>
</div>
on my index.html:
<div oncontextmenu='return false' ondragstart='return false' onmousedown='return false' th:include="common/menu :: [//div[#id='menu']]"></div>
and this is the result of doing view source on the HTML page
<div>
<div class="pure-menu">
<a class="pure-menu-heading" href="index.html">
<img src="../../../images/home.png" width="136" height="43" alt="SL" />
</a>
The attributes of the tag has dissapeared

may be th:replace will solve your problem.

Related

WEIRD BEHAVIOUR of LIGHTBOXES

I've just tried the CSS code written by #ongtiffany on codepen.io about lightboxes.
The code is great, but if I use it on a standalone test (follows)
<body>
<a class="lightbox" href="#first">
<img src="https://drive.google.com/uc?export=view&id=1cKXuGQzX3t65NoYEKfuI4wBHwxUM9wjH"/>
</a>
<div class="lightbox-target" id="first">
<img src="https://drive.google.com/uc?export=view&id=1cKXuGQzX3t65NoYEKfuI4wBHwxUM9wjH"/>
<a class="lightbox-close" href="#"></a>
</div>
<a class="lightbox" href="#second">
<img src="https://drive.google.com/uc?export=view&id=1kLe9YXiM2XdgwKkATwkhfk6kzdnKIefi"/>
</a>
<div class="lightbox-target" id="second">
<img src="https://drive.google.com/uc?export=view&id=1kLe9YXiM2XdgwKkATwkhfk6kzdnKIefi"/>
<a class="lightbox-close" href="#"></a>
</div>
</body>
</html>
It leaves me a weird "_" symbol between the two pictures.
Can you see it? Any advice to eliminate it?
And one more question? What could it be a way to get a window closing by pressing the "ESC" key?
Try this
a.lightbox{
text-decoration:none;
}
OUTPUT

my div is not clickable

I would like my div be clickable. but I have tested multi ways that is possible, but it doesn't work fine :
<a href="https://www.telegram.me/shadyab_deal">
<div id="mob_link" class="home_right_banner_mob">
<img width="360px" height="130px" src="http://www.shadyab.com/assests/images/ic_mob_telegram.jpg"/>
</div>
</a>
Your html is wrong Please used to this
and define your a tag display inline-block;
a{display:inline-block;vertical-align:top;}
<a href="https://www.telegram.me/shadyab_deal">
<div id="mob_link" class="home_right_banner_mob">
<img width="360px" height="130px" src="http://www.shadyab.com/assests/images/ic_mob_telegram.jpg"/>
</div>
</a>
2nd option is your can used to this valid HTML
#mob_link a{display:block;}
<div id="mob_link" class="home_right_banner_mob">
<a href="https://www.telegram.me/shadyab_deal">
<img width="360px" height="130px" src="http://www.shadyab.com/assests/images/ic_mob_telegram.jpg"/>
</a>
</div>
Wrapping block level elements with links is allowed in HTML 5. Just do this.
<a href="https://www.telegram.me/shadyab_deal">
<div id="mob_link" class="home_right_banner_mob">
<img width="360px" height="130px" src="http://www.shadyab.com/assests/images/ic_mob_telegram.jpg"/>
</div>
</a>

HTML code same for each image, links not all working

I've coded http://www.meghanbustardphotography.com/home/ and have linked each image to a different page (html code below). However, only the first link in each row is functioning. How can I fix this?
<div class="row" class="aligncenter">
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2014/09/colin-karlee-abbotsford-backyard-wedding/">
<div id="colinkarlee"></div>
</a>
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2014/09/andrew-rebecca-whytecliff-park-engagement/">
<div id="andrewrebecca"></div>
</a>
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2014/05/justin-hilary-south-bonson-wedding-2/">
<div id="justinhilary"></div>
</a>
</div>
<div class="row" class="aligncenter">
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2014/07/greg-amanda-beach-grove-wedding/">
<div id="gregamanda"></div>
</a>
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2014/10/cory-nicole-fort-langley-little-white-house-wedding/">
<div id="corynicole"></div>
</a>
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2013/09/mike-renae-whonnock-lake-portraits/">
<div id="mikerenae"></div>
</a>
</div>
<div class="row" class="aligncenter">
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2014/08/david-gastown-portraits/">
<div id="david"></div>
</a>
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2014/09/brent-stephanie/">
<div id="brentstephanie"></div>
</a>
<a target="_blank" href="http://www.meghanbustardphotography.com/blog/2014/08/sean-brittany-langley-golf-centre-wedding/">
<div id="seanbrittany"></div>
</a>
</div>
By taking a look at your real page, only 1st column has < div > inside < a >< /a >
<a href="http://www.meghanbustardphotography.com/blog/2014/09/colin-karlee-abbotsford-backyard-wedding/" target="_blank">
<div id="colinkarlee"></div>
</a>
For 2nd and 3 column, I see the < div >(s) are outside of < a >< /a >. That's the reason why they are not clickable
<div id="andrewrebecca"></div>
<div id="justinhilary"></div>
Put <div id == ... >
INTO <a target .. /a>
I did it and the links worked after that.
I can provide pictures if you don't know what I mean
You have a bunch of <p> links in your view page source code that do not have closing </p> tags associated with them. Try taking those out and see if that helps.
Also, check out the order of the <a> and <div> tags in your actual code. They're not matching what you pasted in your question.
I think it might wordpress not processing/showing your HTML directly. Try these:
https://wordpress.org/plugins/insert-php/
https://wordpress.org/plugins/allow-php-in-posts-and-pages/

The tilde (~) in the one of the images doesn't get resolved

This is a funny one.
I have a page using knockoutjs.
Everything works fine apart from one of the images in the page that doesn't show.
My HTML
<div class="cyclerItem"> #*Views and Visitors*#
<div class="cyclerFilter">
<img class="toggleImg" src="~/Content/imgs/City.png" width="30" height="30" />
</div>
<div class="cyclerFilterText">
<div>
<a id="modal-launcher4" > Business Unit </a>
<div id="modal-content4" class="arrow_box">
<div id="scroll4" class="scroll4">
<div id="container3column" >
<div id="primary1">
<p>Business Unit</p>
<ul>
<li>All</li>
</ul>
<ul data-bind="'foreach': businessUnits.businessUnitsList">
<li data-bind="'text': title, 'click': goToFunctions""></li>
</ul>
</div>
</div> #* Container ends*#
</div> #* scroll *#
</div> #*modul content 4 4 *#
</div>
</div> #* Cykler filter text*#
<div class="cyclerFilter">
<img class="toggleImg" src="~/Content/imgs/Globe_Alt.png" width="30" height="30" />
</div>
<div class="cyclerFilter">
<img class="toggleImg" src="~/Content/imgs/Globe_Alt.png" width="30" height="30" />
</div>
<div class="cyclerFilterText">
Geographies
</div>
</div>
My HTML rendered on the Client:
<div class="cyclerItem">
<div class="cyclerFilter">
<img class="toggleImg" src="/Content/imgs/City.png" width="30" height="30" />
</div>
<div class="cyclerFilterText">
<div>
<a id="modal-launcher4" > Business Unit </a>
<div id="modal-content4" class="arrow_box">
<div id="scroll4" class="scroll4">
<div id="container3column" >
<div id="primary1">
<p>Business Unit</p>
<ul>
<li>All</li>
</ul>
<ul data-bind="'foreach': businessUnits.businessUnitsList">
<li data-bind="'text': title, 'click': goToFunctions""></li>
</ul>
</div>
<div id="content1">
<p>Function</p>
<ul>
<li>All</li>
</ul>
<ul data-bind="'foreach': functions.functionsList">
<li data-bind="'text': title, 'click': goToDepartments"></li>
</ul>
</div>
<div id="secondary1">
<p>Department</p>
<ul>
<li>All</li>
</ul>
<ul data-bind="'foreach': departments.departmentsList">
<li data-bind="'text': title"></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="cyclerFilter">
<img class="toggleImg" src="~/Content/imgs/Globe_Alt.png" width="30" height="30" />
</div>
<div class="cyclerFilter">
<img class="toggleImg" src="/Content/imgs/Globe_Alt.png" width="30" height="30" />
</div>
<div class="cyclerFilterText">
Geographies
</div>
</div>
as you can see there only one small difference, one of the image have the source where the tilde (~) didnøt get resolved inot the right path.
It's only that one image in that position, if I change the source to another path it still does not work, but as you can see the next image is exactly the same but it works...
something to do with mvc messing around because of the knockout code?
Or maybe just a simple error in my html that make MVC get crazy? First coming first serving. :)
I actually found the problem. It's probably a pure HTML problem.
There is an extra double quote at the end of one attribute in a li tag. :)
I made some tests and it doesn't matter where but if any attribte in any tag as an extra double quote, that img stop working. I wonder why that img src and not something else.

CKeditor replacing HTML on load

I have an instance of CKEditor running to edit small parts of a website. The original HTML is:
<div class="slide slideleft">
<a href="#" class="slidelefta">
<img src="img/left.png" alt="previous" />
</a>
</div>
<div class="slide slidemid noauto" style="height: auto; text-align: center;">
<a href="#" class="sliderighta">
<img src="img/main_item.png" alt="item" />
</a>
</div>
<div class="slide slideright">
<a href="#" class="sliderighta">
<img src="img/right.png" alt="next" />
</a>
</div>
now, when I load it into CKEdit (inside a <textarea>, all correctly encoded with PHP's htmlspecialchars() method), it replaces all my carefully crafted DIVs and styles with the following:
<p><img alt="previous" src="img/left.png" /></p>
<p><img alt="burg.ring1" src="img/main_item.png" /></p>
<p><img alt="next" src="img/right.png" /></p>
which of course totally ruins the page's layout. Can CKEditor somehow be set to not do that?
Thank you!
Since CKEditor 4.1 the Advanced Content Filter feature is enabled. You need to configure it in order to have your HTML passing the validation. See my previous answer here: CKEditor strips inline attributes.