I'm using ejs templates for my webpage, and I'm having layout troubles.
I have a button inside a <div> that's set to display:none as a dropdown, and should show up when the container is hovered over. Instead, the buttons that should be in the dropdown are rendered outside of it and have seemingly no relation to it.
Source ejs file:
<button class="mdc-button mdc-button--raised dropdown" id="clear">
Clear
<div class="mdc-card dropdown-content">
<p>Test</p>
<button>TestButton</button>
</div>
</button>
And the resulting page according to chrome's element viewer:
<button class="mdc-button mdc-button--raised dropdown" id="clear">
Clear
<div class="mdc-card dropdown-content">
<p>Test</p>
</div>
</button>
<button>TestButton</button>
The <p> tag still displays correctly
I don't believe you can put a button element within a button element.
Try it out on MDN here:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
This is the example input I put into their live editor. When you inspect the button, you'll get the same output as you've shared in your post.
<button class="favorite styled"
type="button">
<button>Hello</button>
Add to favorites
</button>
Depending on where you need the button, you could try styling the outside or inside element to look like a button as a work around!
Related
Below is my first attempt to build a Razor page w/ Boostrap. When the page is first brought up, the form is collapsed. When the user clicks on the Revisit a quote button, the form then expand. I followed the documentation on Bootstrap's site to the dot, but no idea getting the toggle to work. What am I missing?
#page "/"
<div>
<label>What would you like to do?</label>
<div>
<button class="btn btn-primary"
type="button">
Create a new quote
</button>
</div>
<div>
<button class="btn btn-primary"
type="button"
data-toggle="collapse"
data-target="#quotesearchForm"
aria-expanded="false"
aria-controls="quotesearchForm">
Revisit a quote
</button>
<div class="collapse" id="quotesearchForm">
<form>
<input /><div class="dropdown" /><button></button>
</form>
</div>
</div>
</div>
Mystery solved...out of the box Blazor only has the bare-bones structure from Bootstrap and does not have the javascript portion. What Blazor wants you to do is to use its code to eliminate the use of javascript. Blazor does that by using its SignalR technology to transmit very small amount of data over the wire to do that. Tim Corey has a YouTube video on this.
i have been trying to add icon from http://seehowsupport.com/font-awesome/ website to my p-button.
<div class="ui-g-12">
<button pButton id="selectFile" (click)="selectFile()" label="+ Select File..."></button>
</div>
here, in place of '+' in label, i wish to set icon from above url. I have heard changing some content attribute in css to \f067 can do it but m not sure how to.
Thanks
Icon on a button is specified with icon attribute and position is customized using iconPos attribute. Default icon position is left. To display only an icon, leave label as undefined.
Here are two ways by which you can add icons to primeng Button.
<button pButton type="button" icon="pi pi-check" iconPos="left"></button>
<p-button label="Click" icon="fa fa-check" iconPos="left"></p-button>
working Example
For more read on documentation -
https://primefaces.org/primeng/#/button
Use This way where it shows in their documentation and it works.
<div class="ui-g-12">
<button pButton id="selectFile" (click)="selectFile()" label="Select File..."><i class="fas fa-500px"></i>Text</button>
</div>
Link for How to use it https://fontawesome.com/how-to-use/svg-with-js
I've a sign up form with a really simple markup which doesn't support accessibility. It is basically following:
<div class="responsiveCell responsiveCellSize2">
<div class="alignBottom minSize2">
<div id="cont_id_f_c816dab2f221e8118135e0071b652f51" class="stat_group checkbox-container group group-id-cont_id_f_c816dab2f221e8118135e0071b652f51 has-children">
<input class="floatLeft" id="f_c816dab2f221e8118135e0071b652f51" name="f_c816dab2f221e8118135e0071b652f51" leadfield="" contactfield="" aria-labelledby="label-cont_id_f_c816dab2f221e8118135e0071b652f51" type="checkbox">
<span style="font-family:Arial; font-weight:normal; font-size:16px; color:#A40084;" class="group-title active" id="label-cont_id_f_c816dab2f221e8118135e0071b652f51" role="button" aria-expanded="true" tabindex="0">Economy</span>
</div>
</div>
<div class="clear"> </div>
<div style="alignTop minSize2">
<div id="required_info_f_c816dab2f221e8118135e0071b652f51" class="requiredInfo floatLeft">
</div>
</div>
</div>
<div class="responsiveCell responsiveCellSize1 emptyCell"> </div>
And this pattern occurs about 50 times on the page. This markup already has my extra markup for supporting accessibility.
Markup cannot be changed in the backend.
Now I'm facing an issue where user cannot proceed to next element while pressing tab.
Keyboard navigation stops to first instance of a SPAN element which has following attributes:
role="button"
aria-expanded="true"
tabindex="0"
If I take your code snippet and repeat it several times in a test file, I can successfully tab to each checkbox and each "Economy" label. It's a little unusual to have the label of a checkbox be a button instead of plain text, but there isn't anything invalid about the html. The screen reader announces it just fine.
"Economy check box not checked"
"Economy button expanded"
"Economy2 check box not checked"
"Economy2 button expanded"
"Economy3 check box not checked"
"Economy3 button expanded"
I have the following html:
<li class="list-group-item li-tab-1">
<div class="list-group-item-desc" data-target="#tab-1" data-toggle="tab">
<strong>1</strong>
<div class="small m-t-xs">
<p>Description</p>
</div>
<div class="onoffswitch">
<input type="checkbox" checked="checked" class="onoffswitch-checkbox" id="tab-1-enabled" /> <label class="onoffswitch-label" for="tab-1-enabled"> <span
class="onoffswitch-inner"></span> <span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</li>
This is a Bootstrap tab. .onoffswitch is a CSS3 switch.
I'm trying to make the entire <li> clickable to show #tab-1 as the tab content. I can do this by defining a <div> with the data-target and data-toggle attributes. This works - when I click the div the tab shows.
However, embedded inside the <li> is a CSS3 switch. I want that to work independently of the clickable div.
This is similar to Links inside of larger clickable areas (CSS Only), except the nested clickable elements are CSS3 switches instead of anchors.
Using the CSS3 switch outside the anchor works fine.
I tried making the actual hidden checkbox visible, removing the CSS3 styling, and clicking that. That does work, so is this related to CSS3?
I wondered if this is related to propogation - the trouble is that if I set an event listener for control.select or change I get no events - just the div click event.
Turned out it was propogation that was the problem (thanks #TW80000).
$(".list-group-item-desc").click(function(ev) {
var isSwitchClick = $('.onoffswitch').has($(ev.target)).length > 0;
if(isSwitchClick) {
ev.stopPropagation();
}
});
That checks whether the click was inside the switch, and if so stops propogation.
In reality I have since moved the Bootstrap tab attrributes into the <li> but I think either approach should work to avoid swallowing the event.
Please help,
I am getting error via http://validator.w3.org/ while validating my html5 template. I get the message "The element button must not appear as a descendant of the a element.". I can't understand this. Could anyone help me to solve this?
Here is my code:
<div class="post-response btn-group btn-group-lg">
<button type="button" class="btn btn-default"><i class="fa fa-comment"> 5 Comments</i></button>
<button type="button" class="btn btn-default"><i class="fa fa-heart"> 5 Likes</i></button>
</div>
The usual error from the W3C validator is:
The element button must not appear as a descendant of the a element
This makes more sense for your question, as you have a button that is a descendant of an anchor.
Normally, you could solve the issue by simply styling your anchor tag, or by placing the button within a form element:
<form style="display: inline" action="http://www.example.com/" method="get">
<button>Some Call to Action</button>
</form>
But in your case, I don't think you even need the anchors as you aren't linking anywhere using HTML (and if you are attaching events using JavaScript, you could simply attach those events to the button rather than the anchor.