So i was looking into Pagination dependency in ReactJS. My code is working fine but the formatting of pagination is quite out of order. How can i improve my pagination outlook. It's currently showing as bullets
<Pagination
activePage={this.state.activePage}
itemsCountPerPage={18}
totalItemsCount={this.state.totalBooks}
pageRangeDisplayed={3}
onChange={this.handlePageChange} />
It's showing in the browser as the attached image
From the docs of react-js-pagination:
The component comes with no built-in styles. HTML layout compatible with Bootstrap pagination stylesheets.
So if you are using Bootstrap, it should just work.
If not the package provide some props to set classes to different elements, and then you should style them :
innerClass, activeClass, activeLinkClass, itemClass, itemClassFirst, itemClassPrev, itemClassNext, itemClassLast ...
You have to acquire some notion about DOM scaffolding and CSS:
ul {
list-style: none;
padding: 0;
}
ul li {
display: inline-block;
}
ul li a {
text-decoration:none;
color: #999;
}
ul li a:hover, ul li a.active {
color: #333;
}
<ul>
<li><a href="#" /><</a></li>
<li><a href="#" class="active"/>1</a></li>
<li><a href="#" />2</a></li>
<li><a href="#" />></a></li>
</ul>
So i found the Mobile Stepper of material-ui helpful in this case. I imported import MobileStepper from '#material-ui/core/MobileStepper';
I just had to make a simple updatePage(i) function that took +1 or -1 depending upon the next or previous page and corresponding any other function calls can be done in update page function. Hence easily pagination can be done and new information can be rendered accordingly. Although this is not the exact correct method, but it helped me with my functionality.
<MobileStepper steps='5' position='static' activeStep='1' nextButton={<Button size='small' onClick={this.updatePage.bind(this,1)}/>Next</Button>} backButton={ <Button size='small' onClick={this.updatePage.bind(this,-1)} disabled={this.props.match.params.pageNo <= 1}>Prev</Button>} />
Related
I'm trying to follow the documentation here:
https://getbootstrap.com/docs/5.0/components/list-group/
"Numbers are generated by counter-reset on the , and then styled and placed with a ::before pseudo-element on the with counter-increment and content."
<ol class="list-group list-group-numbered contract">
<li class="list-group-item border-0 contract">
copy
</li>
<li class="list-group-item border-0 contract">
more copy
</li>
</ol>
I've only just moved to BS 5.0, so that could be my confusion.
CSS works to change the font-size/color but not the style.
li.contract::before {
font-size: 2.25rem !important;
color: #AED6DE !important;
list-style-type: lower-roman !important;
}
I can't find any examples of numbered Lists in BS 5.0, just the brief explanation in the BS docs.
Any examples/guidance would be much appreciated.
Add the property content: counter(section, lower-roman) ". "; to your li.contract::before class or to the li.list-group-item::before class like so:
li.list-group-item::before {
font-size: 2.25rem;
color: #AED6DE;
content: counter(section, lower-roman) ". ";
}
Instead of using the list-style-type: property.
Explanation: This is because they mention in the Bootstrap 5.0 documentation (you were on the right track but it is a bit obscure) in the Numbered Section, that "Numbers are generated by counter-reset on the <ol>, and then styled and placed with a ::before pseudo-element on the <li> with counter-increment and content." So the counter needs to be styled/specified within the <li> css instead of specifying the list-style-type: property directly on <ol> or <li>. The counter css works by initializing it with a name and setting it to zero on the <ol> (parent element) using the counter-reset: section property, adding the counter to the <li> with the content: property, and then styling it with the same idea you were using to get the color and size to work (within/selecting the <li>, and in this case the counter name is section - which I found with an inspect).
I need help with setting up a wordpress menu.
I made my html css but when I go under wordpress and when I use the wp_nav_menu () function I lose my specific id on <a> tags, Wordpress automatically generates new <li> <a>.
How can I select them from the class "menu_word" please?
<ul class="menu_word">
<li><a id="home" href="#">Tilte1</a></li>
<li>Tilte2</li>
<li>Tilte3</li>
<li>Tilte4</li>
<li><a id="sem" href="#">Tilte4</a></li>
<li>Tilte5</li>
</ul>
There you go
body .menu_word >li:nth-child(1)> a{ /*Title1 on pos 1 (specific for first level of menu)*/
border:1px solid red;
}
body .menu_word >li:nth-child(2)> a{ /*Title2 on pos 2 (specific for first level of menu)*/
border:1px solid blue;
}
<ul class="menu_word">
<li><a id="home" href="#">Tilte1</a></li>
<li>Tilte2</li>
<li>Tilte3</li>
<li>Tilte4</li>
<li><a id="sem" href="#">Tilte4</a></li>
<li>Tilte5</li>
</ul>
Can you add a class and target that?
If not, this will work, although its pretty brittle. It'll become more robust if you can add a class to the UL, but if you can add a class, you may as well add it to the <a> tag, or the <li> tag.
body > ul > li:nth-child(1) > a
Thank you for your answers, I also find a solution that I share if it can help.
<ul class="menu_word">
<li><a id="home" href="home">Tilte1</a></li>
<li>Tilte2</li>
<li>Tilte3</li>
<li>Tilte4</li>
<li><a id="sem" href="sem">Tilte4</a></li>
<li>Tilte5</li>
</ul>
a[href*="home"]{
font-weight: 800;
font-size: 1.2em;
}
a[href*="sem"]{
text-transform: capitalize;
}
I'm using Bootstrap 3. I have this menu which works ok only when is not a touch (mobile) device:
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Inicio</li>
<li>Ayuda</li>
<li>Metodología<span></span>
<div class="nav-sub-menu">
<ul class="text-submenu">
<li style="padding-left=0px">Guía Metodológica</li>
<li style="padding-left=0px">Modelos y Resultados</li>
</ul>
</div>
</li>
<li>Glosario</li>
<!--<li>Link de Interés</li>-->
<li>Contacto</li>
</ul>
</div>
In the css, the hover that give the style to the elements have this code:
.nav li > a {
display: table-cell;
}
.nav>li>a:hover {
background: none;
color: #ff7113;
}
.nav > li > ul {
display:none;
list-style:none;
position:relative;
}
.nav > li:hover > ul {
display:block;
}
I've read some posts about making menus for both desktop and touch without hover, with javascript or even using external libraries. Is there are more simple way to use this menu in mobiles devices?
I made a Jsfiddle with the menú working:
https://jsfiddle.net/esqkx349/
You have to open it in a wide screen to see it, like this:
in case, anyone still finding solution to this problem,
Add onclick="void(0)" in <div class="navbar-collapse collapse"> to make mobile device recognise an element as an element with a hover.
like <div class="navbar-collapse collapse" onclick="void(0)">
Well, I made it:
https://jsfiddle.net/pmiranda/bwkyocpa/1/
I had to put some javascript and css:
function isTouchDevice(){
return typeof window.ontouchstart !== 'undefined';
}
$(document).ready(function(){
/* If mobile browser, prevent click on parent nav item from redirecting to URL */
if(isTouchDevice()) {
// 1st click, add "clicked" class, preventing the location change. 2nd click will go through.
$(".navbar-nav > li > a").click(function(event) {
// Perform a reset - Remove the "clicked" class on all other menu items
$(".navbar-nav > li > a").not(this).removeClass("clicked");
$(this).toggleClass("clicked");
if ($(this).hasClass("clicked")) {
event.preventDefault();
}
});
}
});
CSS:
.hover-hack {
position: fixed !important;
background-color: rgba(0, 0, 0, 0.7) !important;
}
#media only screen and (max-width:1024px) {
.hover-hack {
background: rgba(0, 0, 0, 1) !important;
z-index: 10;
}
}
And the html:
<li>Metodología<span></span>
<ul class="text-submenu hover-hack">
<li style="padding-left=0px">Guía Metodológica</li>
<li style="padding-left=0px">Modelos y Resultados</li>
</ul>
</li>
<li>Glosario</li>
It's possible to make a clickable dropdown without Js.
The hover method is sketchy because some touch devices will treat the first click like a hover action.
It can be done using a checkbox html element. Then, css can detect wether or not the checkbox is current checked.
I created a component that does the job using this link. It works fairly well on mobile because click events work just fine.
Pure CSS clickable dropdown?
Problem is, this solution is slightly hacky and pure HTML, CSS implementations can't work outside of the HTML heirarchy.(so if your button and your dropdown menu exist in different branches of the html heirarchy it won't work.)
I think the most appropriate solution is to use a little bit of JS and handle the element on click.
I am creating a navigation structure. I tried to use AngularStrap and Bootstrap, but as soon as I injected them into my app, Angular failed. I found this link and constructed my navigation tab-bar. I like how easy it is to customize. My problem is, I don't know how to apply the css for the selected tab in angular. I can't apply an id to an element conditionally, and when I try and break up the css into multiple classes, the tabs don't display the same way.
<ul class="tablist">
<li ng-repeat="tab in tabList" ng-click="setSelected($index);">
{{tab.title}}
</li>
</ul>
vs.
<ul class="tablist">
<li id="selectedTab">Admin</li>
</ul>
What is the best way to apply the selected formatting? See this Fiddle for a more fleshed out example.
Updated: http://jsfiddle.net/dLemh/6/
to have background color change use css important on the class
ng-class="{selected: isSelected(tab)}"
$scope.currentSelectedTab = {};
$scope.setSelectedTab = function(tab){
$scope.currentSelectedTab = tab
}
$scope.isSelected = function(tab){
if(tab == $scope.currentSelectedTab){
return true;
}
return false;
}
Please let me know if anything
I found this SO Post that I was able to use and fix the CSS formatting with regards to their priority.
.tablist li.selectedTab a {
background: none;
border: 2px solid #6B74C6;
border-bottom: 0px;
background-color: #F3F3F3;
color: #0378D9;
text-decoration: none;
}
<ul class="tablist">
<li ng-repeat="tab in tabList" ng-click="setSelected($index);" ng-class="{ selectedTab: $index === selected}">
{{tab.title}}
</li>
</ul>
I have an ul with 7 li inside of it. I know that I can style the first and last li but is it possible to style the last 3 li's so the text is a different colour? This is the first time I have come across this problem/dilemma. I have googled around a bit and have not found much that is really helping me.
<div class="international-portfolio">
<div class="international-portfolio-title"> Sales Representation International</div>
<ul class="nobullet inline int-portfolio ">
<li class="excelsior-hotel-ernst first">
<li class="le-mas-candille">
<li class="mandarin-oriental-hotel-group-worldwide">
<li class="victoria-jungfrau-grand-hotel-spa">
<li class="palace-luzern">
<li class="eden-au-lac">
<li class="bellevue-palace last">
</ul>
</div>
ive updated the coding - trying the solutions given but not working at the moment but will keep at it.
This should do the trick (but mind you, it won't work in older versions of IE):
http://reference.sitepoint.com/css/pseudoclass-nthlastchild
Use the css selector as follows:
li:nth-last-child(-n+3) {
/*stuff here*/
}
Here's an example, too:
http://jsfiddle.net/yAUwb/
You can use:
li:nth-last-child(1), li:nth-last-child(2), li:nth-last-child(3) {
color: red;
}
It is kinda of possible with this code
.myList li:nth-last-child(1),
.myList li:nth-last-child(2),
.myList li:nth-last-child(3)
{
color: red;
}
Demo: http://jsfiddle.net/2np58/