I'm trying to use Bootstrap's Pagination style. The documentation says to create the page list like so:
<div class="pagination">
<ul>
<li class="disabled">«</li>
<li class="active">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>»</li>
</ul>
</div>
The first two links, the left arrow and the 1, should be disabled. When I incorporate it into my django template though, those two are still usable. Clicking them sends the user to the top of the page just like any other anchor link with an id "#". I think I still have to have the there in order for Bootstrap to style it correctly.
Is there a way to write this so that when the user clicks one of the disabled "buttons" it doesn't do anything?
In the docs, those buttons are just disabled manually. It has nothing to do with the .pagination styling.
You could use that
$('.pagination .disabled a, .pagination .active a').on('click', function(e) {
e.preventDefault();
});
Note: If you use an ajax based pagination you have to put this piece of code in the update handler or use delegated events instead
If you write the html dynamically server side (with django for example) and you don't want to use javascript you could do this:
pseudo code:
if (Model.HasNext()) {
<li> // normal link
next
</li>
} else {
<li class="disabled"> // disabled link
next
</li>
}
As a reference, here is what Bootstrap does:
&.disabled,
&[disabled] {
cursor: not-allowed;
pointer-events: none; // Future-proof disabling of clicks
.opacity(.65);
.box-shadow(none);
}
$('.disabled a').click(function(){
return false;
});
For PHPLD v 4.2 I used the following code to show Bootstrap 3 pagination
{* Display Paging Links *}
<ul class="pagination">
<li>{paginate_prev id="MainPaging"}</li>
{paginate_middle id="MainPaging" format="page" prefix="" suffix="" link_prefix="
<li>"link_suffix="</li>" current_page_prefix="
<li class=\"active\">"current_page_suffix="</li>"}
<li>{paginate_next id="MainPaging"}</li>
</ul>
Related
Within a ul element i have a list of anchor tags that represent social media icons like so :
<ul class="social-menu">
<li class="social-item">
...
</li>
<li class="social-item">
...
</li>
<li class="social-item">
...
</li>
<li class="social-item">
...
</li>
</ul>
On Android mobile (the only OS that displays such behaviour by default)i'm noticing that when you click an item the highlight colour will appear correctly the first time. However, after that first time if you select a different icon the highlight appears over the previously selected icon.
I've tried explicitly declaring the -webkit-tap-highlight-color, ensuring the correct anchor tag has been clicked with some console logs for each item and even stripping back the content in the <a> tag to make sure that wasn't interfering but with no luck.
Check the yellow block on the top of this page :)
https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color
You can try :active or :active and :visited instead.
a:active {
background-color: yellow;
}
If you like my answer, please vote. I need some points to write comments :D If its not well answered, write the exact purpouse you need highlighting for. There wil be someone who will help for sure!
I'm trying to change the color of a span when a link is clicked in order to indicate that it's checked. This must work in the form of a radio button, meaning that the color must disappear if another link is clicked (checked). I tried various methods using only html and css, but unfortunately I never managed to get it to work using :focus. At the moment, when I click on one of the filters there is no indication that one of the categories has been activated, heavily impacting the UX. I believe that this can be achieved using ngClass in angular, however, I'm really struggling to understand how this works. Any help would be really appreciated.
HTML:
<div class="checklist categories">
<ul>
<li><a data-action="filter-link" (click)="changeCategory(null)"><span></span>All</a></li>
<li><a data-action="filter-link" (click)="changeCategory('House Favourites')"><span></span>House Favourites</a></li>
</ul>
</div>
The styling of the span forms a small checkbox.
u can use ngClass Demo
in css create your class and write which css you want
.active-link span{background-color:green;}
in html create ngClass for each list item
<ul>
<li><a data-action="filter-link" [ngClass]="{'active-link' : menus.allMenu}" (click)="changeCategory(null,'allMenu')"><span></span>All</a></li>
<li><a data-action="filter-link" [ngClass]="{'active-link' : menus.houseMenu}" (click)="changeCategory('House Favourites','houseMenu')"><span></span>House Favourites</a></li>
</ul>
then in ts create model for menus
menus={allMenu:false,houseMenu:false}
with function first initialize it then change clicked one
changeCategory(el,event){
this.menus.allMenu=false;
this.menus.houseMenu=false;
this.menus[event]=!this.menus[event];
}
Hi i just wanted some help trying to animate my navigation bar. I want the nav link to still be highlight after I have clicked on the page. So for example if I pressed a "home" button while on the home page the home button would be highlighted to just to show that your definitely on this page. Would use :target or ::active?
<div id="header-content">
<div class="hire"><h3>For Hire</h3></div>
<h1>Black Cab Tours</h1>
<nav class="cl-effect-8">
<ul>
<li><a onclick="tours.html" href="#tab1">Tours</a></li>
<li>About</li>
<li>Contact</li>
<li>Review</li>
</ul>
</nav>
</div>
create a css class like
.active {
background: #c2c2c2;
}
when u click on a HOME page link add this class to that li tag through java script here is the code
$('li').click(function(){
$(this).removeClass('active');
$(this).addClass('active');
});
or you can use gt(), lt() selector to remove active class from else li tags
Your best bet is to use Javascript (e.g. jQuery) to assist you, in native CSS :active will only style the current interaction state as it occurs, :target may be unreliable if you rely on routing, and the final option :focus will fail when clicking elsewhere.
By using jQuery you can more tightly maintain control over the application/removal of a selected state, e.g:
$('#header-content li').on('click', function(){
$(this).addClass('selected').siblings().removeClass('selected');
});
This isolates the relevant elements, adds the class selected when you click one, and removes it from its siblings.
Similar to: How to Display Selected Item in Bootstrap Button Dropdown Title
I have a two-level bootstrap menu. I would like when a item is selected and navigated to, that that the drop down list from where the item is, to be always be displayed. Here is my cut down version of the code:
<ul class="menu-system">
<li class="active">
Location
</li>
<li class="dropdown">
Top level Option 1
<ul class="dropdown-menu">
<li> Option 1</li>
<li> Option 2</li>
<li> Option 3</li>
<li> Option 4</li>
</ul>
</li>
Example: When the Top level Option 1> Option 1 page is active I would like to show the drop down menu. What it does at the moment is only display the top level menu. Since its a bootstrap drop down it will shown by default which is the correct way a drop down menu should work. Not sure if I can make it be shown dynamically. This should always been shown regardless if a user clicks off it or anything else on that page.
I am working in an ASP.NET application. I'm not sure that is has to do with the active tag, or if I have to write some javascript/jquery code to get the current page and display the appropriate drop down menu.
Any help greatly appreciated.
JSFiddle: jsfiddle.net/yZ8C6
Right, I'll preface this by saying that I couldn't get it to work properly in jsfiddle because it doesn't reload the page when the named links are clicked however, I believe this should help
$('.dropdown-menu li a').each(function() {
if($(location).attr('href').indexOf($(this).attr('href')) > 0) {
$('.dropdown-menu').show();
}
});
So what we're doing here is checking the link href on each list item and checking if it is contained within the page link. If any of them are matched, the dropdown will be set to show. Since bootstrap uses visibility and show() uses display:block, the show() should override the visibility: hidden when you stop hovering
See how you go - you might need to modify it slightly for your own purpose
http://jsfiddle.net/yZ8C6/1/
You can get the fiddle to work if you click one of the links then reload the output frame only
I would like the entire box to be a link to my page tomatoes.html, however the user has to click specifically on the word "tomatoes" to go to the new page. How can I make its surrounding box also a link? I tried to do
<a><li>a href="tomatoes.html">Tomatoes</li></a>
but my research tells me this is not proper HTML coding. Any ideas? Thanks.
<div class="subMenu subGrub">
<ul>
<li>Tomatoes</li>
<li>Potatoes</li>
</ul>
</div>
Leave it to this:
<li>Tomatoes</li>
and use this CSS to get the whole <li>-element to be "clickable":
li > a {
display: block;
}