Make COL occupy the entire space dynamically - html

I have an application that list's some content on page dynamically. So we choose some achievement, and create a section that have from 1 to X achievements and on this page, they're listed using col-md-x.
I want to use the col-md-6 size, because I have some elements that's dynamic and I need some space to show it.
But my problem here is, I want to make the columns to use the empty space, for example this image:
The red area, below section 'informe um nome2' isn't occupied, but I want to show the third, 'informe um nome3' below this section and use the free space.
Here's my current code:
<div class="row col-md-12">
#foreach (var item in Model)
{
<div class="col-md-6" style="margin-bottom:20px">
<div class="card">
#if (item.SectionHeader != null)
{
<div class="card-header text-center" style="height: 120px; background-image: url('#item.SectionHeader.ImageURL'); background-size:cover; color:black">
#item.SectionName <a title="Renomear" ng-click="Rename(#item.SectionID)"><i class="fa fa-xs fa-clipboard" style="cursor:pointer"></i></a> <a title="Baixar arquivo da seção" ng-click="DownloadFiles(#item.SectionID, false)"><i class="fa fa-xs fa-download" style="cursor:pointer; color:green"></i></a> <a title="Apagar seção" ng-click="Delete(#item.SectionID)"><i class="fa fa-xs fa-trash" style="cursor:pointer; color:red"></i></a>
</div>
}
else
{
<div class="card-header text-center">
#item.SectionName <a title="Editar" href="#Url.Action("EditSection", "Guides", new { sectionID = item.SectionID })"><i class="fa fa-xs fa-edit" style="cursor:pointer; color:orange"></i></a> <a title="Renomear" ng-click="Rename(#item.SectionID)"><i class="fa fa-xs fa-clipboard" style="cursor:pointer"></i></a> <a title="Baixar arquivo da seção" ng-click="DownloadFiles(#item.SectionID, false)"><i class="fa fa-xs fa-download" style="cursor:pointer; color:green"></i></a> <a title="Apagar seção" ng-click="Delete(#item.SectionID)"><i class="fa fa-xs fa-trash" style="cursor:pointer; color:red"></i></a>
</div>
}
<div class="card-body">
#foreach (var chievo in item.GameAchievements.OrderBy(f => f.SectionOrder.HasValue ? f.SectionOrder : f.AchievementID))
{
<div class="achievement" id="#chievo.AchievementID" style="margin-top:10px; margin-bottom:10px; z-index:1; height:60px">
<ul style="list-style:none; margin-top:20px; padding-left:0px" id="#chievo.AchievementID">
<img src="#chievo.Icon" style="float:left" />
<b> #chievo.DisplayName</b>
<br />
#if (string.IsNullOrEmpty(chievo.Description))
{
 <i class="fa fa-edit" style="cursor:pointer" ng-click="OpenModal(#chievo.AchievementID)"></i>
}
else
{
 <i>#chievo.Description</i>
}
<div style="float:right" class="text-center">
<a title="Alterar Dificuldade" ng-click="ChangeDifficulty(#chievo.AchievementID)"><i class="fa fa-xs fa-star" style="cursor:pointer; margin-left:10px; color:orange"></i></a>
<a title="Remover da Seção" ng-click="RemoveFromSection(#chievo.AchievementID)"><i class="fa fa-xs fa-trash-alt" style="cursor:pointer; margin-left:10px; color:red"></i></a>
</div>
#if (chievo.Difficulty != null)
{
<img src="#chievo.Difficulty.DifficultyImage" style="float:right; width:32px" />
}
</ul>
</div>
if (item.SectionDivisor != null && (item.IndividualDivisor.HasValue && item.IndividualDivisor.Value == true))
{
<div class="text-center">
<img src="#item.SectionDivisor.DivisorImageURL" />
</div>
}
}
#if (item.SectionDivisor != null && (item.IndividualDivisor.HasValue && item.IndividualDivisor.Value == false))
{
<div class="text-center" style="margin-top:20px">
<img src="#item.SectionDivisor.DivisorImageURL" />
</div>
}
</div>
</div>
</div>
}
</div>
So, basically, I want help making the columns auto-align and auto-fill.
I'm using sb admin 2 free template version.

In this case that won't work as desired, because the elements follow a row column distribution and when two elements fill a row, the next element goes all the way down to the space the longest element of the first two occupies and starts there.
What you could use in this case is something like Isotope using the horizontal masonry layout. You can check more on this on Isotope's docs.
If you still prefer to use the bootstrap option I would recommend you define a height for each column and make it scrollable. That would be the easiest way to order them visually.

Related

How to show images inside <a> tags inside <div> tags?

I am trying to create social media icons using svg files in a footer. If I use inline css, it works. If I don't, it does not show. I am using styled-components package.
Any idea how can I get it to work without inline css?
This works:
<div style={{ width: '25px', margin: '0 5px' }}>
<a href={link}>
<img src={iconName} alt={(iconName, 'icon')} />
</a>
</div>
This does NOT work:
const iconSocial = styled.div`
width: 25px;
margin: 0 5px;
`;
<iconSocial>
<a href={link}>
<img src={iconName} alt={(iconName, 'icon')} />
</a>
</iconSocial>
This also does NOT work:
<div>
<a href={link}>
<img src={iconName} alt={(iconName, 'icon')} />
</a>
</div>
if you want show image between a tag then we have two option first one our custom image (also you need to write some css to its styling) and second is using fa icon you can use any method according to your requirement.
<a href="">
<img src="https://static.vecteezy.com/system/resources/thumbnails/001/993/889/small/beautiful-latin-woman-avatar-character-icon-free-vector.jpg" alt="" srcset=""> Profile
</a>
<hr>
<i class="fa fa-facebook-square" aria-hidden="true"></i>Facebook
<i class="fa fa-twitter" aria-hidden="true"></i> Twitter
<i class="fa fa-linkedin" aria-hidden="true">Linkdin</i>
.svg-img{
width: 100px;
height: 100px
}
<div>
<a href="">
<img class="svg-img" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0xNC44NTEgMTEuOTIzYy0uMTc5LS42NDEtLjUyMS0xLjI0Ni0xLjAyNS0xLjc0OS0xLjU2Mi0xLjU2Mi00LjA5NS0xLjU2My01LjY1NyAwbC00Ljk5OCA0Ljk5OGMtMS41NjIgMS41NjMtMS41NjMgNC4wOTUgMCA1LjY1NyAxLjU2MiAxLjU2MyA0LjA5NiAxLjU2MSA1LjY1NiAwbDMuODQyLTMuODQxLjMzMy4wMDljLjQwNCAwIC44MDItLjA0IDEuMTg5LS4xMTdsLTQuNjU3IDQuNjU2Yy0uOTc1Ljk3Ni0yLjI1NSAxLjQ2NC0zLjUzNSAxLjQ2NC0xLjI4IDAtMi41Ni0uNDg4LTMuNTM1LTEuNDY0LTEuOTUyLTEuOTUxLTEuOTUyLTUuMTIgMC03LjA3MWw0Ljk5OC00Ljk5OGMuOTc1LS45NzYgMi4yNTYtMS40NjQgMy41MzYtMS40NjQgMS4yNzkgMCAyLjU2LjQ4OCAzLjUzNSAxLjQ2NC40OTMuNDkzLjg2MSAxLjA2MyAxLjEwNSAxLjY3MmwtLjc4Ny43ODR6bS01LjcwMy4xNDdjLjE3OC42NDMuNTIxIDEuMjUgMS4wMjYgMS43NTYgMS41NjIgMS41NjMgNC4wOTYgMS41NjEgNS42NTYgMGw0Ljk5OS00Ljk5OGMxLjU2My0xLjU2MiAxLjU2My00LjA5NSAwLTUuNjU3LTEuNTYyLTEuNTYyLTQuMDk1LTEuNTYzLTUuNjU3IDBsLTMuODQxIDMuODQxLS4zMzMtLjAwOWMtLjQwNCAwLS44MDIuMDQtMS4xODkuMTE3bDQuNjU2LTQuNjU2Yy45NzUtLjk3NiAyLjI1Ni0xLjQ2NCAzLjUzNi0xLjQ2NCAxLjI3OSAwIDIuNTYuNDg4IDMuNTM1IDEuNDY0IDEuOTUxIDEuOTUxIDEuOTUxIDUuMTE5IDAgNy4wNzFsLTQuOTk5IDQuOTk4Yy0uOTc1Ljk3Ni0yLjI1NSAxLjQ2NC0zLjUzNSAxLjQ2NC0xLjI4IDAtMi41Ni0uNDg4LTMuNTM1LTEuNDY0LS40OTQtLjQ5NS0uODYzLTEuMDY3LTEuMTA3LTEuNjc4bC43ODgtLjc4NXoiLz48L3N2Zz4=">
</a>
</div>

How to show tooltip only for a particular hovering div which are dynamically generated

I have the following div
<div class="col-sm" title="Device Name" id="titleDevice" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Name</div>
I am trying to show tooltip as below by pointing to the id of this element. This is working fine.
showTooltip("#titleDevice");
function showTooltip(idOfElement) {
$(idOfElement).hover(function() {
$(idOfElement).tooltip('show');
});
}
My issue is, in the page, sometimes there will be many such div which are dynamically generated. For that case, this selecting by id will not work and thus I tried selecting by class.
Example of such scenario with some number of div as below
<form method="post" id="qaForm">
<div class="card" style="background-color:white; color: white; position: relative; border-color: black; !important ">
<div class="card-body">
<div class="row">
<div class="col-sm" title="Device Name" class="titleDevice" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Name</div>
<div class="col-sm" title="second" class="second" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Second</div>
<div class="col-sm" title="third" class="third" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i>third</div>
</div>
</div>
</form>
showTooltip(".titleDevice");
function showTooltip(classOfElement) {
$(classOfElement).hover(function() {
$(classOfElement).tooltip('show');
});
}
Then used the same JQuery function. But when I hover over to one div, all the other div also showing the tooltip at the same time. Does anyone know how to solve this problem?
To show the tooltip for only that particular element, use this keyword
showTooltip(".titleDevice");
function showTooltip(idOfElement) {
$(idOfElement).hover(function() {
$(this).tooltip('show'); // Use 'this' here
});
}
If you want tooltip for dynamically generated div then use only
$(document).tooltip();
This will work for all div. You need not include the hover method.
You can preview below code:
$(document).tooltip();
//for dynamically add
$(document).on('click', '#add', function(){
$('#div').html('<div class="col-sm" title="Mobile Name" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Name</div>');
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<div class="col-sm" title="Device Name" id="titleDevice" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Name</div>
<hr />
<button id="add">Add New</button>
<hr />
<div id="div"></div>

html page arrange correctly only after reload

I am working with angular, html and css.
I build a widget that includes a table of 3*3.
For some reason, in the first upload - the table takes only 50 percent from the widget width.
It looks OK only after reload.
Does someone have an idea what could be the problem?
<div widget class="card">
<div class="card-header">
<span>Select service(s)</span>
<div class="widget-controls">
<a data-widgster="expand" href="#" class="transition"><i class="fa fa-chevron-down"></i></a>
<a data-widgster="collapse" href="#" class="transition"><i class="fa fa-chevron-up"></i></a>
<a data-widgster="fullscreen" href="#" class="transition"><i class="fa fa-expand"></i></a>
<a data-widgster="restore" href="#" class="transition"><i class="fa fa-compress"></i></a>
</div>
</div>
<table id="serviceTable">
<tr *ngFor="let eachService of [0,1,2]; let i = index">
<td *ngFor="let j of [0,1,2]" class="service-td" >
<div>
<input name="checkboxes" type="checkbox" (change)="changeListener($event, i+j)">
<span>osnat11111111</span>
</div>
</td>
</tr>
</table>
<br>
</div>
</div>
The css is:
.service-td
{
table-layout:fixed;
width:10vw;
overflow:hidden;
padding: 0.5vw;
}
Thanks,
Osnat
You can just try,
...
<div style = "width: 100%">
<table> ... </table>
</div>
width: 100% gives the same width of the CSS component to the child

How can I make a button with delete and a link together?

I have a button to go to a link, but when the visitor is the user that created the page, that button needs to also have an X so it can be deleted by the user-owner.
1) Tags: The solution that works has the problem that: I can make the 2 buttons, but it is difficult to spot visually which X corresponds with each button (when there is more than one).
2) Tags: On the other side, when I put them together you can not click on the X, because it always takes you to the buttons' link.
NEED: I need a button with two parts, one for the delete X and another for the link of the text, but I do not see how to do it. Please, see the image.
<div class="g-mb-30">
<h6 class="g-color-gray-dark-v1">
<button id="jh-create-entity"
*ngIf="owner === post.userId"
class="btn btn-primary float-right jh-create-entity create-tag"
[routerLink]="['/tag/new']" [queryParams]="{ 'postIdEquals': post.id }">
<fa-icon [icon]="'plus'"></fa-icon>
</button>
<strong class="g-mr-5">Tags:</strong>
<span *ngFor="let tag of post.tags">
<a (click)="removePostTag(tag.id, post.id)">
<fa-icon [icon]="'times'"></fa-icon>
</a>
<a [routerLink]="['/tag', tag.id, 'view' ]" class="u-tags-v1 g-font-size-12 g-brd-around g-brd-gray-light-v4 g-bg-primary--hover g-brd-primary--hover g-color-black-opacity-0_8 g-color-white--hover rounded g-py-6 g-px-15 g-mr-5">
{{tag.tagName}}
</a>
</span>
</h6>
<h6 class="g-color-gray-dark-v1">
<button id="jh-create-entity"
*ngIf="owner === post.userId"
class="btn btn-primary float-right jh-create-entity create-tag"
[routerLink]="['/tag/new']" [queryParams]="{ 'postIdEquals': post.id }">
<fa-icon [icon]="'plus'"></fa-icon>
</button>
<strong class="g-mr-5">Tags:</strong>
<span *ngFor="let tag of post.tags">
<a [routerLink]="['/tag', tag.id, 'view' ]" class="u-tags-v1 g-font-size-12 g-brd-around g-brd-gray-light-v4 g-bg-primary--hover g-brd-primary--hover g-color-black-opacity-0_8 g-color-white--hover rounded g-py-6 g-px-15 g-mr-5">
<span>
<a (click)="removePostTag(tag.id, post.id)">
<fa-icon [icon]="'times'"></fa-icon>
</a>
</span>
{{tag.tagName}}
</a>
</span>
</h6>
EDIT Wayne: This does not work since the X (delete) does not work
<h6 class="g-color-gray-dark-v1">
<button id="jh-create-entity"
*ngIf="owner === post.userId"
class="btn btn-primary float-right jh-create-entity create-tag"
[routerLink]="['/tag/new']" [queryParams]="{ 'postIdEquals': post.id }">
<fa-icon [icon]="'plus'"></fa-icon>
</button>
<strong class="g-mr-5">Tags:</strong>
<section style="display: flex; justify-content: space-around;">
<span *ngFor="let tag of post.tags">
<a [routerLink]="['/tag', tag.id, 'view' ]" class="u-tags-v1 g-font-size-12 g-brd-around g-brd-gray-light-v4 g-bg-primary--hover g-brd-primary--hover g-color-black-opacity-0_8 g-color-white--hover rounded g-py-6 g-px-15 g-mr-5">
<span>
<a (click)="removePostTag(tag.id, post.id)">
<fa-icon [icon]="'times'"></fa-icon>
</a>
</span>
{{tag.tagName}}
</a>
</span>
</section>
</h6>
Currently, in your second solution (which I recommend from a UX standpoint), you have the X icon within the element that links to /tag.
If you move that icon to the outside of your anchor, it should work properly.
Check my quick example below.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
</head>
<body>
<section style="display: flex; justify-content: space-around;">
<span style="border: 1px solid gray; padding: 5px;">
<a onclick="remove()"><i class="fas fa-times"></i></a>
<a onclick="link()">Link</a>
</span>
<span style="border: 1px solid gray; padding: 5px;">
<a onclick="remove()"><i class="fas fa-times"></i></a>
<a onclick="link()">Link</a>
</span>
<span style="border: 1px solid gray; padding: 5px;">
<a onclick="remove()"><i class="fas fa-times"></i></a>
<a onclick="link()">Link</a>
</span>
<span style="border: 1px solid gray; padding: 5px;">
<a onclick="remove()"><i class="fas fa-times"></i></a>
<a onclick="link()">Link</a>
</span>
</section>
</body>
<script>
function remove() {
alert('Removed an element!');
}
function link() {
alert('Clicked a link!');
}
</script>
</html>
Edit: Changed to use FA so that it is hopefully more clear.
Edit: Here is an example of how you would apply what I am explaining in your own code. If this does not work, inspect your CSS.
<h6 class="g-color-gray-dark-v1">
<button id="jh-create-entity" *ngIf="owner === post.userId" class="btn btn-primary float-right jh-create-entity create-tag"
[routerLink]="['/tag/new']" [queryParams]="{ 'postIdEquals': post.id }">
<fa-icon [icon]="'plus'"></fa-icon>
</button>
<strong class="g-mr-5">Tags:</strong>
<section style="display: flex; justify-content: space-around;">
<span *ngFor="let tag of post.tags">
// Note that here I have moved the X link to be a child of the span
<a (click)="removePostTag(tag.id, post.id)">
<fa-icon [icon]="'times'"></fa-icon>
</a>
// The tag name link is on the same level as the X (child of the span)
<a [routerLink]="['/tag', tag.id, 'view' ]" class="removed-classes">
{{tag.tagName}}
</a>
</span>
</section>
</h6>

No bottom arrow on Bootstrap Tool tip on table

I'm trying to use an Bootstrap tool tip in a bootstrap table. More or less it works as it should. But i can get it to show the small arrow at the bottom. I have no problems getting it to work outside an table.
<div class="imgtooltip displayInLineBlock" data-toggle="tooltip" data-placement="top" title="" data-original-title="History">
<a class="breakDownListShowEquipLongText " href="#" data-notificationid="5000">
<img class="vcenter marginTopMinus2 displayInLineBlock" src="/api/Icon/GetIcon/?size=15&iconkeyname=MMS_ViewLog" alt="MMS"></a></div>
$('a[data-toggle="tooltip"]').tooltip({
animated: 'fade',
placement: 'top',
});
.cart {
overflow:hidden;
margin-top:20px;
padding:10px 20px;
background: yellow;
}
<div class="cart">
<a data-toggle="tooltip" title="add to cart">
<i class="icon-shopping-cart"></i>
</a>
</div>
Demo : JSFiddle
Update:
You can change placement to top,bottom,right,left