I need some help with Primefaces datatable pagination buttons. I'm replacing icons on pagination buttons with FontAwesome icons. Here is a CSS example what I did for one of them (I modified others the same way):
div.ui-paginator > a.ui-paginator-prev > .ui-icon.ui-icon-seek-prev {
text-indent: 0;
}
div.ui-paginator > a.ui-paginator-prev > .ui-icon.ui-icon-seek-prev::before {
font-family: FontAwesome;
content: "\f048";
}
I refreshed my page and I've noticed that icons get replaced but now a new character appears on the right side of each Font Awesome icon (F, P, N, and E).
I believe it has to do something with locales where N stands for Next, P is Previous, E is End and F is First. I've had the same problem with the calendar component and I modified my locales.js to solve that issue. I would also like to remove these pagination characters if possible.
How can I do that?
Is it possible to modify the (1 of 150) to my locale language as well?
EDIT 1
Html after replacement looks like this:
Old icons have been removed as described above with the same css procedure only different selectors. I am not using any custom paginators for this, only default Primefaces datatable pagination.
My DataTable xhtml tag is:
<p:dataTable id="DTableA" var="dataObject" value="#{dataTableBean.objectList}" paginator="true" rows="10" rowKey="#{dataObject.id}"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15,25,50" reflow="true">
EDIT 2
Following #Jasper de Vries answer didn't resolve my issue because the posted answer is somewhat deprecated. Main selector is incorrect for Primefaces 6.2.
See the following selector:
.ui-paginator > span:before, .ui-sortable-column-icon:before {
font-family: FontAwesome; color: #fff;
}
.ui-paginator > span:before is incorrect. Should be .ui-paginator > a:before for Primefaces 6.2.
Also I had to replace sorting caret icons from suggested answer with these:
.ui-icon-carat-2-n-s.ui-icon-triangle-1-n:before {
content: "\f0d8";
}
.ui-icon-carat-2-n-s.ui-icon-triangle-1-s:before {
content: "\f0d7";
}
and resize them:
.ui-sortable-column-icon {
height: 20px;
}
And second part of my question
Is it possible to modify the (1 of 150) to my locale language as
well?
hasn't been answered yet.
SOLUTION
I've finally figured out what happened when I wrote css like this:
div.ui-paginator > a.ui-paginator-prev > .ui-icon.ui-icon-seek-prev {
text-indent: 0;
}
div.ui-paginator > a.ui-paginator-prev > .ui-icon.ui-icon-seek-prev::before {
font-family: FontAwesome;
content: "\f048";
}
Each icon for the pagination should be replaced with a FontAwesome icon inside the <a> tag and not inside the <span> tag as I did.
It's interesting that the icon class by Primefaces is placed inside the <span> tag and it confused me to think that an icon is placed inside it. Instead it's actually a wrapper tag for text I tried to hide which was already hidden by default. Setting text indent to 0 and adding an icon to that particular span exposes the hidden text.
<a href="#" class="ui-paginator-next ui-state-default ui-corner-all" aria-label="Next Page" tabindex="0">
<span class="ui-icon ui-icon-seek-next">N</span>
</a>
Modified selectors do the trick here. Sample CSS is available by #Jasper de Vries. My edited CSS for pagination goes like this:
.ui-paginator.ui-paginator-top.ui-widget-header.ui-corner-top,
.ui-paginator.ui-paginator-bottom.ui-widget-header.ui-corner-bottom,
.ui-paginator a,
.ui-paginator a:hover {
background: none;
background-image: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
text-shadow: none;
}
.ui-paginator > a {
width: 32px;
height: 32px;
}
.ui-paginator a,
.ui-paginator a:hover {
border: none;
-moz-border-radius: 0;
-webkit-border-radius: 0;
border-radius: 0;
padding: 3px 0px 0px 0px;
color: #fff;
}
.ui-paginator a {
background-color: #1E88E5;
}
.ui-paginator a:hover {
background-color: #1565C0;
}
.ui-paginator a,
.ui-sortable-column-icon:before {
font-family: FontAwesome;
}
.ui-sortable-column-icon.ui-icon {
background-image: none;
text-indent: 0;
margin: 0 0 0 .5em;
height: 20px;
}
.ui-paginator span span,
.ui-paginator a span {
display: none;
}
.ui-paginator .ui-paginator-first:before {
content: "\f048";
}
.ui-paginator .ui-paginator-prev:before {
content: "\f04a";
}
.ui-paginator .ui-paginator-next:before {
content: "\f04e";
}
.ui-paginator .ui-paginator-last:before {
content: "\f051";
}
.ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s.ui-icon-triangle-1-n,
.ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s.ui-icon-triangle-1-s {
margin: 0px 0px 0px 0px;
}
.ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s.ui-icon-triangle-1-n {
top: -2px;
}
.ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s.ui-icon-triangle-1-s {
top: 4px;
}
.ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s:before {
content: "\f0dc";
}
.ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s.ui-icon-triangle-1-n:before {
content: "\f0d8";
}
.ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s.ui-icon-triangle-1-s:before {
content: "\f0d7";
}
Thank you #Jasper de Vries and #Kukeltje for your help.
Related
I am trying to learn ASP Core and Razor by developing a simple project to present verb conjugations for different tenses to a user. As part of the project, I have an options page at the start with a couple of dropdown lists (using HTML select components) to select the verbs to present and the order to present them in.
One of the dropdowns (the order selector) works as I would expect, i.e. it displays with a single value and a dropdown arrow to the right of it that opens the list when clicked (see picture below). The other (verb selector) displays 4 items in a box with a scroll-bar to the right of the list and no dropdown selector. Both use the same code and underlying data and I can't understand why they are behaving differently. I want them both to behave like a dropdown (single line with dropdown selector to the right).
Does anyone know how I can get them to behave the same way? Screen shot and code segments included below.
This is a screen shot of the two select components. The verb selector is on top and the order selector is underneath.
The verb selector has the following HTML (it forms part of a set of options and so has a radio input, but there is no interaction between these components.
I have commented out the radio input and it makes no difference to how the select component displays):
<td>
<input type="radio" name="selverbs" value="sel" id="sel" onclick="javascript:topenable()" />
<label for="top">Selected verbs </label>
<select name="verbs" asp-for="selectedverbs" asp-items="Model.verbs"></select>
</td>
The order selector has the following HTML:
<td>
<label>Verb order: </label>
<select name="order" asp-for="selectedorder" asp-items="Model.order"></select>
</td>
Both selectors use Lists with SelectListItems in them.
The data for the verb selector is created like this:
public List<SelectListItem> GetVerbs()
{
List<SelectListItem> results = new List<SelectListItem>();
int rank = 1;
foreach (string s in collection.AsQueryable().OrderBy(doc => doc.Rank).GroupBy(doc => doc.Rank).Select(g => g.First().Infinitive))
{
results.Add(new SelectListItem(s, rank.ToString(CultureInfo.CurrentCulture)));
rank++;
}
return results;
}
The data for the order selector is generated as follows:
[BindProperty]
public List<SelectListItem> order { get; } = new List<SelectListItem>
{
new SelectListItem { Value = "1", Text = "forward" },
new SelectListItem { Value = "-1", Text = "reverse" },
new SelectListItem { Value = "0", Text = "random" }
};
I have tried setting size="1" on the verb selector and this has not made any difference. This component still displays with a scroll bar (see screen shot below).
I don't think I have anything in my CSS file that would cause this difference, but don't know much about CSS so have included the full file below. This is mostly the default file creat ed by Visual Studio when I set up the project with a couple of additions from me.
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
/* Provide sufficient contrast against white background */
a {
color: #0366d6;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
/* Body layout
-------------------------------------------------- */
div{
color: black;
font-weight:normal;
}
select {
margin-right: 20px;
overflow-y: auto;
text-align: left;
width: 55px;
}
#incorrect {
color: red;
font-weight: bold;
}
#correct {
color: forestgreen;
font-weight: bold;
}
/* Tooltip container */
.tooltip {
position: relative;
display: inline-block;
border-bottom: none;
}
/* Tooltip text */
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #555;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
/* Position the tooltip text */
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
/* Fade in tooltip */
opacity: 0;
transition: opacity 0.3s;
}
/* Tooltip arrow */
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
/* Sticky footer styles
-------------------------------------------------- */
html {
font-size: 14px;
}
#media (min-width: 768px) {
html {
font-size: 16px;
}
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px; /* Vertically center the text there */
}
I have tested this across Chrome, IE and Edge and get the same outcome each time.
Turns out this isn't a size issue, but a binding issue. It appears to be caused by the binding for the return value (selectedverbs) in the page's associated c# file as follows:
[BindProperty]
public List<SelectListItem> selectedverbs { get; }
Because this will take multiple return values it is setting multiple against the select component. When I changed this to public string selectedverbs { get; } then the select component operates as a standard dropdown, which presumably only allows a single item to be selected.
Bootstrap breadcrumb components in both v3 and v4 add a "/" to list items:
http://getbootstrap.com/components/#breadcrumbs
https://v4-alpha.getbootstrap.com/components/breadcrumb/
The docs say:
Separators are automatically added in CSS through ::before and
content.
So, I looked at the source code, the relevant section showing:
.breadcrumb-item + .breadcrumb-item::before {
display: inline-block;
padding-right: 0.5rem;
padding-left: 0.5rem;
color: #636c72;
content: "/";
}
However, the content: "/"; only exists on the breadcrumb-item rule. Yet, it seems to work when I follow the v3 docs, which don't require a breadcrumb-item class for items inside a list:
<ol class="breadcrumb">
<li class=''>Home</li>
<li class=''>Library</li>
<li class="active">Data</li>
</ol>
JSFiddle
Why does the above HTML with the above CSS result in / separators being added to items in a .breadcrumb list even though they don't have the .breadcrumb-item class and thus can't benefit from the content: "/" rule? Inspecting the output HTML in JSFiddle shows that no bootstrap javascript magic has added a .breadcrumb-item class to my html list items.
link to this style at github (bootstrap v3.3.7):
https://github.com/twbs/bootstrap/blob/v3.3.7/less/breadcrumbs.less
for (bootstrap v4.0.0):
https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.6/scss/_breadcrumb.scss
(bootstrap v3.3.7 --> breadcrumbs.less)
//
// Breadcrumbs
// --------------------------------------------------
.breadcrumb {
padding: #breadcrumb-padding-vertical #breadcrumb-padding-horizontal;
margin-bottom: #line-height-computed;
list-style: none;
background-color: #breadcrumb-bg;
border-radius: #border-radius-base;
> li {
display: inline-block;
+ li:before {
content: "#{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space
padding: 0 5px;
color: #breadcrumb-color;
}
}
> .active {
color: #breadcrumb-active-color;
}
}
(bootstrap v4.0.0 --> _breadcrumb.scss)
.breadcrumb {
padding: $breadcrumb-padding-y $breadcrumb-padding-x;
margin-bottom: $spacer-y;
list-style: none;
background-color: $breadcrumb-bg;
#include border-radius($border-radius);
#include clearfix;
}
.breadcrumb-item {
float: left;
// The separator between breadcrumbs (by default, a forward-slash: "/")
+ .breadcrumb-item::before {
display: inline-block; // Suppress underlining of the separator in modern browsers
padding-right: $breadcrumb-item-padding;
padding-left: $breadcrumb-item-padding;
color: $breadcrumb-divider-color;
content: "#{$breadcrumb-divider}";
}
// IE9-11 hack to properly handle hyperlink underlines for breadcrumbs built
// without `<ul>`s. The `::before` pseudo-element generates an element
// *within* the .breadcrumb-item and thereby inherits the `text-decoration`.
//
// To trick IE into suppressing the underline, we give the pseudo-element an
// underline and then immediately remove it.
+ .breadcrumb-item:hover::before {
text-decoration: underline;
}
+ .breadcrumb-item:hover::before {
text-decoration: none;
}
&.active {
color: $breadcrumb-active-color;
}
}
In version 3 of Bootstrap, the separators are coming from:
.breadcrumb>li+li:before {
padding: 0 5px;
color: #ccc;
content: "/\00a0";
}
on line 6 of the included file breadcrumbs.less.
Hope this helps! :)
When you inspect the element, you get the style to be:
.breadcrumb > li + li:before {
padding: 0 5px;
color: #ccc;
content: "/\00a0";
}
So the above code targets all the descending <li> elements inside the .breadcrumb element.
The logic is pretty simple. The next element has a breadcrumb before.
There is a CSS rule like this:
.breadcrumb>li+li:before {
padding: 0 5px;
color: #ccc;
content: "/\00a0";
}
Using only CSS, I'm trying to set a list of links to have a exclamation mark next to them if they are 'unvisited' links, and a check box next to them if they have been visited. The former works fine, but when the links have been visited, the tick box doesn't appear. My CSS is as follows:
.journey-table td a:link:before {
content: "\f071";
font-family: FontAwesome;
padding-right: 5px;
}
.journey-table td a:visited:before {
content: "\f14a";
font-family: FontAwesome;
padding-right: 5px;
}
Any help would be greatly appreciated.
According to this page, the styling of a :visited element, has been made very limited, for privacy reasons. Because of this, any child elements or pseudo elements of a visited link will be styled like an unvisited link.
I've created an example for you to understand
a:before {
background-color: blue;
content: "";
display: block;
height: 25px;
width: 25px;
float: left;
margin-right: 10px;
}
a:hover:before {
background-color: red;
}
this is a link
I'm using Less to write CSS, it totally saved much time for me. Now I have small issue, here is my code:
largest fight gym in Australia
Less
.btn{
position: relative;
padding: 15px 22px;
color: #color-black;
&-black-bg{
background: #color-black;
color: #color-white;
}
&-right-skew{
position: relative;
&:after{
content: '';
position: absolute;
right: -10px;
top: 0px;
width: 20px;
height: 100%;
.skewX(-15deg);
}
}
}
Now I my goal is if btn-black-bg so btn-right-skew has black background too. In CSS, I can handle with this code:
.btn-black-bg.btn-right-skew:after{
background: #000;
}
But I don't know how to do this in LESS. Hope everyone can help me out.
Based on your HTML, adding the background: #000 to .btn-black-bg:after (one of the 2 classes) alone is enough but I assume you want to apply some properties only when both classes are present on the same element. For that, you can use the parent selector like below:
.btn {
&-black-bg&-right-skew:after {
background: #000;
color: #fff;
}
}
You cannot nest this into the &-black-bg or &-right-skew (as the order of classes doesn't matter in CSS) and make use of the parent selector because the parent selector would always refer to the full parent and not just the immediate parent. The best that can be done with nesting would be the below but the would need the .btn to be statically added to the innermost selector instead of using &.
.btn {
&-black-bg {
&.btn-right-skew:after {
background: #000;
color: #fff;
}
}
}
You can make use of variables to achieve nesting like mentioned here but I wouldn't recommend it for your scenario because the selector given above is more simple and readable.
I would recomend to separate the clases into a base class "btn" and modifier classes "black-bg" and "right-skew". (In my opinion this makes it easier to understand what is applied and how it can be combined.)
see my axample on codepen: http://codepen.io/fabiandarga/pen/bVNpLE
largest fight gym in Australia<br />largest fight gym in Australia
css:
.btn {
display: inline-block; // added to let the padding affect the height
position: relative;
padding: 15px 22px;
color: #color-black;
&.black-bg{
background: #color-black;
color: #color-white;
}
&.green-bg{
background: #color-green;
color: #color-white;
}
&.right-skew{
position: relative;
&.black-bg { // combine both classes = .right-skew.black-bg
&:after {
background: #color-black;
}
}
&.green-bg:after { // or short form
background: #color-green;
}
&:after {
content: '';
display: block; // was missing;
position: absolute;
right: -10px;
top: 0px;
width: 20px;
height: 100%;
transform: skewX(-15deg); // changed to make it work in the example on codepen
}
}
}
I want to imitate fraction numbers like this: http://projectpophealth.org/images/Multi-Provider_Measure_Page.png
I've already seen alternative ways to display fractions: What would be the math symbol for representing a fraction?
But I really like the look and feel of the horizontal symbol. How do I display it in HTML?
I've made up a simple plain html/css solution, you may want to adjust the font to one more suitable by the way.
jsFiddle
<body>
<div class="fraction">
<p class="num">6</p>
<p class="dem">14</p>
</div>
</body>
.fraction{
display: inline-block;
text-align: center;
position:relative;
padding:0 1em;
}
.fraction > .num {
border-bottom: 2px solid #808080;
padding:4px;
margin:0 0 4px 0;
}
.fraction > .dem{
padding: 0;
margin: 0;
}
.fraction > .num:before{
content: "(";
font-size:2em;
height:100%;
position:absolute;
left:0;
top:0.2em;
}
.fraction > .dem:after{
content: ")";
font-size:2em;
height:100%;
position:absolute;
right:0;
top:0.2em;
}
As you commented that its difficult for you to do so, here's the answer. I've used inline elements and I am turning them to a block level so that they render one below another, and for separating them out, I use border-bottom on the first span element.
Rest, for the top offset, I use position: relative; to settle it down... Rest is self explanatory.
Demo
HTML
<div>(<span><span>18</span><span>26</span></span>)</div>
CSS
div {
font-size: 40px;
color: #515151;
}
div > span {
font-size: 18px;
display: inline-block;
}
div > span > span {
display: block;
padding: 0 5px;
position: relative;
top: 5px;
}
div > span > span:first-child {
border-bottom: 1px solid #515151;
color: green;
}
div > span > span:last-child {
color: tomato;
}
I feel that these types of expressions or over complex ones will get cumbersome to do with CSS Only, hence, take a look at Mathjax