<div class="form-group col-sm-5">
#Html.LabelFor(m => m.foo)
<a data-toggle="popover" data-content="I'm a popover!" href="#"> <span class="glyphicon glyphicon-info-sign"></span></a>
</div>
The <a> element (i.e. the glyphicon popover) appears beneath the label element, but I'd like to have it placed to the right side of the label instead. Is there a way to accomplish this by way of nesting the <a> inside of the #Html.LabelFor? It'd be cool to have something like:
<label for="foo"> I'm the label!
<a data-toggle="popover" data-content="I'm a popover!" href="#"> <span class="glyphicon glyphicon-info-sign"></span></a>
</label>
If not, will I have to use positioning instead?
EDIT: I ended up taking Ramo's advice and rolling with something simple.
<div class="form-group col-sm-5">
<label>
<span> I'm a **hard-coded** LabelFor DataAnnotation! </span>
<a data-toggle="popover" data-content="I'm a popover!" href="#">
<span class="glyphicon glyphicon-info-sign"></span>
</a>
</label>
</div>
Still interested if there's an MVC way to get Glyphicons to cohere with #Html.LabelFor, but my question is more or less academic at this point.
EDIT #2: I found an even easier solution which is kind of obvious in hindsight. This approach uses positioning (i.e. display: inline) to ensure that the accompanying <a> and <span> elements display on the same line.
<div class="col-sm-5 form-group">
#Html.LabelFor(m => m.foo, new { style = "display: inline;" })
<a data-toggle="popover" data-content="I'm a popover!" href="#"> <span class="glyphicon glyphicon-info-sign"></span></a>
</div>
You could use a table and do something like this
<table>
<tr>
<td>#Html.LabelFor(m => m.foo)</td>
<td><a data-toggle="popover" data-content="I'm a popover!" href="#"> <span class="glyphicon glyphicon-info-sign"></span></a></td>
</tr>
</table>
EDIT:
A quick google search brought me to this result which uses CSS to accomplish your goal Label and text box on the same line using css
EDIT 2:
Since you are weary of using tables you might be able to do something like this. I have not tested the code yet, but I do believe it should give you your desired behavior.
HTML:
<div>
<div class="Label">#Html.LabelFor(m => m.foo)</div>
<a data-toggle="popover" data-content="I'm a popover!" href="#"> <span class="glyphicon glyphicon-info-sign"></span></a>
</div>
CSS:
.Label{
display: inline-block;
}
I suggest you go ahead with positioning. Do not take unusual choices here use everything for what is supposed to be used because otherwise you will notice unusual behavior of your code in future.
Try this:
#{
var foo = Html.LabelFor(m => m.foo)
}
<a>#foo</a>
Related
I have this html
<body aurelia-app="main">
<section class="section is-small">
<nav-bar class="au-target" au-target-id="5">
<div class="container">
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item au-target" route-href="route: home" au-target-id="1" href="#/">
<span class="icon is-medium">
<i class="fas fa-lg fa-home" aria-hidden="true"></i>
</span>
</a>
<a role="button" click.delegate="burgerClicked()" aria-label="menu" aria-expanded="false" data-target="myNavBar" class="au-target navbar-burger burger" au-target-id="2">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="myNavBar" class="au-target navbar-menu" au-target-id="3">
<div class="navbar-start">
<div class="navbar-item">
<a route-href="route: games" class="au-target" au-target-id="4" href="#/games">My Games</a>
</div>
</div>
</div>
</nav>
</div>
</nav-bar>
<router-view name="main" class="container au-target" au-target-id="6">
<available-games games.bind="games" class="au-target" au-target-id="11" bindable="games">
<div class="columns">
<ul class="column level">
<li class="level-item">
<game-button game.bind="game" is-available.call="isAvailable( $game )" class="au-target container" au-target-id="9" bindable="game,isAvailable">
<button class="button is-fullwidth is-success au-target" click.delegate="addToMyGames()" disabled.bind="!available" au-target-id="7">
Warhammer 40k
</button>
</game-button>
</li><li class="level-item">
<game-button game.bind="game" is-available.call="isAvailable( $game )" class="au-target container" au-target-id="9" bindable="game,isAvailable">
<button class="button is-fullwidth is-success au-target" click.delegate="addToMyGames()" disabled.bind="!available" au-target-id="7">
Age of Sigmar
</button>
</game-button>
</li><!--anchor-->
</ul>
</div>
</available-games>
</router-view>
</section>
</body>
it looks fine, until I expand it all the way, and then there is no space (height wise) between the full width buttons. I presume, I'm misunderstanding something about how I should be using bulma.
good
bad
note: this is the extent of my scss
#import "~bulma";
#import "~#fortawesome/fontawesome-free/scss/fontawesome.scss";
$fa-font-path: "~#fortawesome/fontawesome-free/webfonts";
#import "~#fortawesome/fontawesome-free/scss/regular.scss";
#import "~#fortawesome/fontawesome-free/scss/solid.scss";
First off, a tip: fix formatting a bit to make it more consistent to readers - more clarity to the HTML hierarchy.
Possible steps:
1) It looks like you might need some padding between each <button> element inside some <style> tags or in your scss file that target the specific class attribute/element you need.
2) I'm confused about your <game-button> element. Is it a custom element you created? If it's not, see the MDN Web Docs for examples of how to create custom HMTL elements if you need it.
3) If <game-button> is not a custom element you created, see Bulma's documentation for buttons because Bulma only requires a <button> element to work (and spacing wouldn't be an issue).
4) Check out this GitHub post regarding spacing between buttons. Although their implementation is different, you may still need to wrap your buttons in a <div class="buttons"></div> element. If there are issues after with inconsistent vertical alignment, I'd suggest using CSS display: flex;, align-items: center, and justify-content: center for centered alignment.
its a sample HTML and I want to get links with mechanize-firefox,which is in <div class="testclass2"> not from others, how can I do it?
<div class="testclass1">
<span class="SelectItem">
<a class="SelectLink">
<span class="SelectText">link1</span>
</a>
</span>
</div>
<div class="testclass2">
<span class="SelectItem">
<a class="SelectLink">
<span class="SelectText">link 1</span>
</a>
</span>
<ul class="SelectList">
<li class="SelectItem">
<a class="SelectLink">link 2</a>
</li>
</ul>
</div>
You can use $mech->xpath to do that. All you need to do is build the right xpath expression to get all a tags under class="testclass2".
my #links = $mech->xpath('//div[#class="testclass2"]//a');
The expression is the most tricky thing about it. The // means anywhere under where you are. This is like div.testclass2 a in CSS.
I have a problem with my verified icon.
So what I actually want is that the verified Icon like on Twitter or Facebook is besides the Username and not in the next line under my username.
But it does not work.
<ul class="line">
<li>
<h3 align="center">Username</h3>
<span class="label label-info">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
</span>
</li>
</ul>
Here is my CSS:
li.line {
list-style: none;
}
ul.line {
display: block;
}
h3 is a block element
change it to inline element
<ul class="line">
<li>
<span align="center">Username</span>
<span class="label label-info">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
</span>
</li>
</ul>
If you don't want the list point, then I don't think li is what you'll want to use. A span or even a div could probably give you the look you're going for.
As for having them on the same line, try using the inline-block option for your css display element. It is similar to display: block, but it allows you to keep your elements on the same line.
In my code I am using bootstrap and adding words to go with the glyphicons. My words are within the span tag and have this awkwardly large space when it is just a normal space.
<div class="first-draft view">
<h4>First-Draft</h4>
<img src="img/view.png" alt="City View"/>
<h5><span class="glyphicon glyphicon-file"> View Report</span></h5>
<h6><span class="glyphicon glyphicon-unchecked"> Compare</span></h6>
</div>
Here is a jsfiddle example http://jsfiddle.net/zbyztda8/
If any of the solution doesn't work, try removing the font-family. I think the spacing is due to font 'Glyphicons Halflings' . Better way is to have text in separate span without any styling and different span for glyphicon.
HTML:
<div class="first-draft view">
<h4>First-Draft</h4>
<img src="img/view.png" alt="City View" />
<h5><span class="glyphicon glyphicon-file"> View Report</span></h5>
<h6><span class="glyphicon glyphicon-unchecked"> Compare</span></h6>
</div>
<br/>
<div class="first-draft view">
<h4>First-Draft</h4>
<img src="img/view.png" alt="City View" />
<h5><span class="glyphicon glyphicon-file"></span><span>View Report</span></h5>
<h6><span class="glyphicon glyphicon-unchecked"> Compare</span></h6>
</div>
Demo: http://jsfiddle.net/zbyztda8/2/
See the last section which doesn't have font-family in span tag.
I have the below HTML. I want to fix the position of the "View All" anchor tag at a particular position. Instead the anchor tag moves as the value in the dropdown changes (i.e according to the length of the changed value in dropdown).
<div class="row " style="margin-left:75pt;">
<div class="dropdown" style="width:300px;display:inline;">
<label class="text-center" id ="categories" style="margin-top:10pt;font-size:14pt;"> Deals on</label>
<button data-toggle="dropdown" class=" btn dropdown-toggle dropdown-menu-hover-color text-center" style="padding:0px 0px;background-color:white;" href="#"><label style="font-size:14pt; color: #191970;" >{{currentCategory}}</label> <b class="caret"></b></button>
<ul class="dropdown-menu submenu-hover-color dropdown-menu-scroll" style="margin:0;">
<li>
{{page.category_name}}
</li>
</ul>
</div>
<div style="display:inline;" ng-show="deals"> View All</div>
<div style="display:inline;" ng-hide="deals"> <label class="text-center" style="margin-top:10pt;font-size:12pt;color: #909090;;">No deals found, please select a different category. </label></div>
</div>
Any pointers on how to achieve this.
Thanks in advance.
try using following html:
<div style="display:inline; position: fixed; top: 100px;" ng-show="deals"> View All</div>
Set the 'top' value as per your need. I think it should help you.