<button class="fa fa-caret-down font-size-18px" style="border: none"
#pop="bs-popover"
[popover]="fil"
placement="bottom right"
[adaptivePosition]="true"
[outsideClick]="true"
(keydown)="keydownEvent($event,pop)">
</button>
In my angular application, I am using a button which will open a popover. But I want it to be a tag or something other than a button because the button will be activated when we press space or enter keys which I don't want. The code should be like this:
<i class="fa fa-caret-down font-size-18px" style="border: none"
#pop="bs-popover"
[popover]="fil"
placement="bottom right"
[adaptivePosition]="true"
[outsideClick]="true"
(keydown)="keydownEvent($event,pop)">
</i>
But this will not trigger the keydown event. What might be the reason for it what are the alternatives? Thanks
I would like to add some picture to route instead of text.
How can I do that?
My example looks like :
<form id="logoutForm" class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="#Url.Action("Index", "Home", new { area = "" })">
<button id="logout" type="submit" class="nav-link btn btn-link text-white">Logout</button>
</form>
I want to have an image in Logout text place.
I can't figure it out. Can someone help me with that simple thing.. ? How can I replace button with an image? I try a lot of img scr etc. But always something is wrong and it didn't works.
There are different ways to do that, I prefer simply put an image into a button:
<button id="logout" type="submit" class="nav-link btn btn-link text-white">
<img src="logout_button.png">
</button>
See: Embed image in a <button> element
so I'm currently trying to disable a button but also have the same button type. If anyone can help me with examples it would be great! Thanks so much to the ones that help! :D
<!--- I want this one to be the working button. --->
<a
class="project-link"
target="_blank"
href="/gimkit"
>Use <i class="fas fa-check-circle"></i> </a
>
<!--- this one to be the button that doesn't work. (disabled)
--->
<a
class="project-link"
target="_blank"
href="/support"
>Help <i class="fas fa-question-circle"></i> </a
>
I want something like this, but have the Help Button with a question mark to be faded instead of the normal button.
https://i.stack.imgur.com/QXRMz.png
For <button> element, just add the disabled property:
<button type="button" disabled>Help</button>
I think the button-elements answer is the best solution.
But if you really want to stick with the Anchor-Tags, you could also try to add a helper css class. For example you can use something like this:
<a
class="project-link disabled"
target="_blank"
href="/support"
onclick="return false;"
>Help <i class="fas fa-question-circle"></i> </a
>
And the css of the .disabled class could look like this:
.project-link.disabled{
opacity:0.5;
}
I am new to programming and just trying to get a simple button to link to google. However it seems every time I press it, it disappears. Any help would be great.
Below I have put my simple button using Boostrap, I just used the button and added an href to link to google with an i class of fa-edit,
<a href="https://www.google.se" class="btn btn-danger">
<i class="fa fa-edit fa-fw"></i>
google
</a>
Fiddle link
I'm sure it's a silly mistake, but any help would be great.
If you add the target attribute it will know to open in a new window I think that is why you are not having any luck making it work in your fiddle.
<a class="btn btn-danger" href="https://www.google.se/"
target="_blank"> <i class="fa fa-edit fa-fw"></i> google</a>
How would one put a link on a button with bootstrap?
there are 4 methods in the bootstrap documentation:
Link Button
<button type="button" class="btn btn-info">Button</button>
<input type="button" class="btn btn-info" value="Input Button">
<input type="submit" class="btn btn-info" value="Submit Button">
The first one doesn't work for me, no button shows, just the text with the link, have a feeling its the theme im using.
The second one shows the button which is what i want, but whats the code make the button link to another page when clicked?
Cheers
The easiest solution is the first one of your examples:
Link Button
The reason it's not working for you is most likely, as you say, a problem in the theme you're using. There is no reason to resort to bloated extra markup or inline Javascript for this.
If you don't really need the button element, just move the classes to a regular link:
<div class="btn-group">
<a href="/save/1" class="btn btn-primary active">
<i class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></i> Save
</a>
Cancel
</div>
Conversely, you can also change a button to appear like a link:
<button type="button" class="btn btn-link">Link</button>
You can call a function on click event of button.
<input type="button" class="btn btn-info" value="Input Button" onclick=" relocate_home()">
<script>
function relocate_home()
{
location.href = "www.yoursite.com";
}
</script>
OR
Use this Code
Link Button
Another trick to get the link color working correctly inside the <button> markup
<button type="button" class="btn btn-outline-success and-all-other-classes">
Button text with correct colors
</button>
Please keep in mind that in bs4 beta e.g. btn-primary-outline changed to btn-outline-primary
This is how I solved
<a href="#" >
<button type="button" class="btn btn-info">Button Text</button>
</a>
Combining the above answers i find a simply solution that probably will help you too:
<button type="submit" onclick="location.href = 'your_link';">Login</button>
by just adding inline JS code you can transform a button in a link and keeping his design.
You can just simply add the following code;
<a class="btn btn-primary" href="http://localhost:8080/Home" role="button">Home Page</a>
Just use the anchor tag as a button. Change the role to type as below in bootstrap 5.
<a type="button" class="btn btn-info" href="#">Button</a>
I think the most easiest and clean approach is (without any extra javascript functions):
<a class="btn" href="#">
<i class="fas fa-cloud"></i>
</a>
To use fontawesome icons, you can just put the following link in your header:
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
And that's all
As you are asking with Bootstrap, the best option in my opinion is to choose the class btn-link.
<button type="button" class="btn btn-link">Link</button>
If you want the btn-link to send you to another page or activate something such as a modal, you can include the onClick like others suggested.
If you really need the button element, a nice trick that I found to make it work looks like this:
Create a data attribute with the url that you want to redirect
Attach an event listener to fetch the url from the data attribute on element
Open the url using window.open or your preferred method
Html file
<button type="button" id="newpagebutton" class="btn btn-primary mt-4 ml-3">Open new page</button>
Javascript file
$( "#newpagebutton" ).attr('data-buttonlink', 'https://www.apple.com')
$( "#newpagebutton" ).click(function() {
const buttonlink = $("#newpagebutton").data('buttonlink')
window.open(buttonlink)
});
Have a look at how the implementation works on fiddle.js
<div>
<a href='#' className='text-decoration-none'>
<button className="btn btn-primary btn-lg px-5 d-flex justify-content-center" type='submit'>Sign In</button>
</a>
</div>