Primefaces menuitem change custom icon - jsf

I have some problems to customize the icon of menuitem component.
I tried this form but i don't have success:
<p:menuitem value="Clientes" outcome="/clientes/CadastroCliente" icon="resources/images/person.png"/>
I too try use css
<p:menuitem value="Clientes" outcome="/clientes/CadastroCliente" icon="user"/>
.user{
background: url('resources/images/menu/users.png') no-repeat;
height:16px;
width:16px;
}
I use PrimeFaces 5.

Try this
<p:menuitem value="Clientes" outcome="/clientes/CadastroCliente" icon="user"/>
.user {
background: url(../images/menu/users.png) !important;
height:16px;
width:16px;
}
You need !important to overwrite the default image of Primefaces and create the folder images directly under src directory

primeFaces 6
If you don’t want to create your own skin and setup the style directly and show a icon/image only,
You can do this:
Note, there is no value=”avoid” attribute inside the tag.
<p:menuitem url="./config.xhtml" styleClass="myStyleName"/>
The result is:
<li role="menuitem">
<a tabindex="-1"
class="ui-menuitem-link ui-corner-all myStyleName"
href="./Konfiguration.xhtml">
<span class="ui-menuitem-text"></span>
</a>
</li>
Note there will be a empty traffic blow up span tag.
used style:
a.ui-menuitem-link.ui-corner-all.myStyleName{
background: url("img/zahnrad.png") no-repeat;
background-size: 1em;
width: 1em;
height: 1em;
}
Important is the background-size in my case 1em
If you would like to add a icon with text so do this:
<p:menuitem url="./Konfiguration.xhtml"
styleClass="myStyleName" value="navigation" />
The result is:
<li role="menuitem">
<a tabindex="-1" class="ui-menuitem-link ui-corner-all myStyleName" href="./config.xhtml">
<span class="ui-menuitem-text">navigation</span>
</a>
</li>
used style:
a.ui-menuitem-link.ui-corner-all.myStyleName{
background: url("img/zahnrad.png") no-repeat;
background-size: 1em;
padding-left: 1.2em; /* reserved text space */
/*
right to left
background-position: right;
padding-right: 1.2em;
*/
}

Related

How to get text in a CSS grid nested in a flexbox to wrap first?

TL;DR: Here's a CodePen.
I have a UI with an image and a grid of text with long lines which looks like this:
I'm using CSS Flexbox with two elements: the image and the text. And then to lay out the text, I'm using CSS Grid. Now, when I view this on a narrow screen for mobile, it correctly wraps everything and stacks the two elements:
But on desktop, with a slightly narrower div, the flex box wraps before the grid text like this:
How can I get the text to wrap while leaving the flex box alone in this case? I fear I may need to use some media queries, but I'm not even sure if I'm using the right CSS components for this.
Here's the code:
index.html:
<div class="media-callout">
<div class="media-thumb">
<img height="170" width="120">
</div>
<div class="media-callout-grid">
<div class="media-callout-key">Authors</div>
<div>Babalola, J & Ogunkola, Babalola</div>
<div class="media-callout-key">Year</div>
<div>2013</div>
<div class="media-callout-key">Title</div>
<div class="media-callout-value">Scientific Literacy: Conceptual Overview, Importance and Strategies for Improvement</div>
<div class="media-callout-key">Journal</div>
<div><em>Journal of Educational and Social Research</em></div>
<div class="media-callout-key">Location</div>
<div>vol. 3, no. 1, pp. 265–274</div>
<div class="media-callout-key">DOI</div>
<div>10.5901/jesr.2013.v3n1p265</div>
</div>
</div>
style.css:
.media-callout {
display: flex;
flex-wrap: wrap;
justify-content: center;
row-gap: 20px;
column-gap: 10px;
padding: 1em;
max-width: max-content;
}
.media-thumb img {
float: left;
height: 175px;
width: auto;
}
.media-callout-grid {
display: grid;
font-size: 12pt;
grid-template-columns: 6em 1fr;
align-content: center;
gap: 0 15px;
}
.media-callout-key {
text-align: right;
font-weight: bold;
}
.media-callout-value {
word-break: break-word;
word-wrap: break-all;
}
A media query does indeed resolve this:
#media screen and (min-width: 600px) {
.media-callout {
flex-wrap: nowrap;
}
}
The query must come AFTER the .media-callout block. I also had to use this approach to prevent the image from being squashed.

Div Background-color is not working

I am hoping to have a navigation bar run across the entire screen, with a purple background and a to have a the menu sit in the middle of the bar. Right now I cant get the background color to work.
My Css:
div#main-navigation {
background-color: #AC56B8;
width: 100%;
height: 100px;
}
My Html:
<div class="main-navigation">
<ul id="menu">
<li>HOUSE</li>
<li>BABY</li>
<li>MORE</li>
<li>ABOUT</li>
</ul>
</div>
You are using wrong css selector # is for ids, to select element by class you have to use ., so the first line of your CSS must be: div.main-navigation {
Look for this:
Replace div#main-navigation for div.main-navigation
div.main-navigation {
background-color: #AC56B8;
width: 100%;
height: 100px;
}
<div class="main-navigation">
<ul id="menu">
<li>HOUSE</li>
<li>BABY</li>
<li>MORE</li>
<li>ABOUT</li>
</ul>
</div>
Write . instead of #
# is for id, . is for class.

Why is the button on my site not working?

If you look here... http://matiny.tk/Mixed%20Swim/Mixed.html
This is a simple site I'm making. It uses Bootstrap to switch the menu when the screen shrinks. Nicely enough, the Menu label/checkbox combo is not working, though it has worked on another site of mine. This is the relevant code...
<label for="menulogo" id="menulabel" class="visible-sm visible-xs"><img src="Menu.png"></label>
<input type="checkbox" id="menulogo">
</nav>
<nav id="menu">
SHOP
ABOUT
BLOG
GALLERY
CONTACT
</nav>
label {
font-size: 40px;
width: 100%;
color: white;
z-index: 2;
}
#menulogo {
opacity: 0;
}
#menu a {
background: rgba(0,0,0,.35);
font-size: 50px;
color: white;
height: 75px;
}
#menu {
margin-top: 100px;
text-align:center;
z-index: 3;
display: none;
position: fixed;
}
#menulogo:checked + #menu {
display: block;
}
As it turns out, my order of elements was incorrect. If one is going to use something like... #menulogo:checked + #menu, then the + or ~ selector means that the nav with #menu has to go right after the checkbox input, like so...
<label for="menulogo" id="menulabel" class="visible-sm visible-xs"><img src="Menu.png"> MENU</label>
<input type="checkbox" id="menulogo">
<!--These must be in sequence-->
<nav id="menu">
SHOP
ABOUT
BLOG
GALLERY
CONTACT
</nav>

Applying css to a Web Content Display Portlet in Liferay

I have used Web Content Display Portlet on my page to display some text. I have to apply css and insert some images for those. I have put the html code in the source. HOw do I apply css for it?
Here is the source that will go in my Web Content Display Portlet
<div class="products" style="width:1000px;">
<div class="tvc box">
<img alt="ADVISORY" title="ADVISORY" src="Index_files/ADVISORY.PNG">
<div class="txt">
<p class="hdtxt"><cufon style="width: 78px; height: 16px;" alt="ADVISORY" class="cufon cufon-canvas"><canvas style="width: 85px; height: 16px; top: 1px; left: -1px;" height="16" width="85"></canvas><cufontext>ADVISORY</cufontext></cufon></p>
</div>
Know More </div>
<div class="tvc box">
<img alt="Branch Locator" title="Branch Locator" src="Index_files/branchlocator.jpg">
<div class="txt">
<p class="hdtxt"><cufon style="width: 68px; height: 16px;" alt="BRANCH " class="cufon cufon-canvas"><canvas style="width: 82px; height: 16px; top: 1px; left: -1px;" height="16" width="82"></canvas><cufontext>BRANCH </cufontext></cufon><br><cufon style="width: 73px; height: 16px;" alt="LOCATOR" class="cufon cufon-canvas"><canvas style="width: 80px; height: 16px; top: 1px; left: -1px;" height="16" width="80"></canvas><cufontext>LOCATOR</cufontext></cufon></p>
<p>Use our branch locator to find the branch closest to you!</p>
</div>
Know More </div>
<div class="tvc box">
<img alt="EMI Calculator" title="EMI Calculator" src="Index_files/emicalculator.jpg">
<div class="txt">
<p class="hdtxt"><cufon style="width: 30px; height: 16px;" alt="EMI " class="cufon cufon-canvas"><canvas style="width: 44px; height: 16px; top: 1px; left: -1px;" height="16" width="44"></canvas><cufontext>EMI </cufontext></cufon><br><cufon style="width: 102px; height: 16px;" alt="CALCULATOR" class="cufon cufon-canvas"><canvas style="width: 109px; height: 16px; top: 1px; left: -1px;" height="16" width="109"></canvas><cufontext>CALCULATOR</cufontext></cufon></p>
<p>Knowing your home loan EMI is just a click away!</p>
</div>
Know More </div>
<div class="tvc box">
<img alt="FAQs" title="FAQs" src="Index_files/faqs.jpg">
<div class="txt">
<p class="hdtxt"><cufon style="width: 39px; height: 16px;" alt="FAQs" class="cufon cufon-canvas"><canvas style="width: 48px; height: 16px; top: 1px; left: -1px;" height="16" width="48"></canvas><cufontext>FAQs</cufontext></cufon></p>
<p>Get the answers to frequently asked questions here.</p>
</div>
Know More </div>
</div>
Each div with class "tvc box" has to appear one after another horizontally.
HOw do I apply css for it?
As administrator you can access the look and feel configuration of yout portlet.
Clicking on options icon,and choose Look and Feel.
You can see several tabs:Text styles,Background styles, border styles, advanced styling.
Advanced Styling tab allows you to enter CSS code to customize your portlet.
You can find how to do that in:
http://www.liferay.com/es/documentation/liferay-portal/6.2/user-guide/-/ai/look-and-feel-liferay-portal-6-2-user-guide-04-en
Also you can do a new theme for your site and put there your custom.css (I think is the best option, because you need to put images)
http://www.liferay.com/es/documentation/liferay-portal/6.2/development/-/ai/creating-themes-and-layout-templates-liferay-portal-6-2-dev-guide-09-en

JSF commandbutton - styling

Is it possible to style JSF commandbutton tags to look like the following example:
http://www.bloggerswatch.com/internet/css-trick-submit-button-should-look-same-everywhere/
It works for the commandlink/
Yes, you should be able to do something similar using slightly different CSS that incorporates the images as CSS backgrounds rather than <img> tags:
Markup
<div class="buttons">
<h:commandButton value="Button Text" styleClass="apply"/>
<h:commandButton value="Button Text" styleClass="cross"/>
</div>
CSS
.buttons input {
margin: 5px;
padding: 5px 5px 5px 20px; /* 20px makes room for your background image */
border: 1px solid #aaa;
}
.buttons .apply {
background: #eee url(path/to/apply.png) no-repeat 0 50%;
}
.buttons .cross {
background: #eee url(path/to/cross.png) no-repeat 0 50%;
}

Resources