<div class="card-body p-0">
<ul class="list-group list-group-flush">
<li class="list-group-item d-flex justify-content-between" th:each="extraConfig : ${extraConfigsPage.content}">
<div>
<a class="item-link">
<span class="item-name ml-2" th:text="${extraConfig.description}"></span>
</a>
</div>
<div>
<a class="btn btn-outline-danger" data-toggle="modal" data-target="#deleteReportModal">
<i class="fas fa-trash-alt"></i>
</a>
</div>
</li>
</ul>
</div>
This is my code. My problem is that the first item in the list (the first div) is not aligned in the center of the icon that exists in the same row. I want the first item to be aligned totally left and in the center of the row, and the second one to be aligned totally right and again in the center (with this code the second item is perfectly aligned).
I don't want to use extra CSS, I want to use only bootstrap classes.
Any ideas? Thanks in advance!
If you could add the bootstrap class align-baseline to your anchor tag for the icon, it will move the icon up to the center of the list item, and that should line up the icon with the center of your left-side tag:
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/js/bootstrap.bundle.min.js"></script>
<div class="card-body p-0">
<ul class="list-group list-group-flush">
<li class="list-group-item d-flex justify-content-between">
<div>
<a class="item-link">
<span class="item-name ml-2">Fling</span>
</a>
</div>
<div>
<a class="btn btn-outline-danger align-baseline" data-toggle="modal" data-target="#deleteReportModal">
<i class="fas fa-trash-alt"></i>
</a>
</div>
</li>
</ul>
</div>
I removed the th: so the snippet has plain HTML and I added a word with a descender in the first tag for comparison.
Related
I have two divs that represent a list of elements the user can click on on a search bar, followed by a "Done" button.
<div class="dropdown col" id="dropdown-search-id">
<input type="text" class="form-control dropdown-toggle" id="inputSearch" placeholder="Search for a term ">
<div class="col dropdown-menu" aria-labelledby="inputSearch">
<div id="search_list_container">
<ul id="inputSearchEntries">
<li id="searching_li" style="visibility:hidden">
<img src="{{static_dir}}/loader.gif" alt="Loading" style="width:15%"/>
</li>
</ul>
</div>
<div id="doneSearchButton" class="d-flex justify-content-end">
<button type="submit" class="btn btn-primary">Done</button>
</div>
</div>
</div>
Whenever the user starts typing, there are a number of <li> elements that appear with an autocomplete function (that is, they are appended between the <ul> tag, but the position of the "Done" button is messed up, as it does not stay at the bottom, that is, below the list elements.
How can I keep the button always at the bottom of the list, regardless of how many elements there are?
See example below. I used your code, added a few <li> items, the data-bs-toggle and a class on the <ul> list so no bullets appear, and the buttons is where it should be.
So if your problem isn't solved with my example, post the full example of the dropdown, with the search results and including any custom CSS.
Other options:
Use the helper class float-end instead of using flex.
Place the btn inside the list: <ul><li>..</li><li><btn></li></ul>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<div class="dropdown col" id="dropdown-search-id">
<input type="text" class="form-control dropdown-toggle" id="inputSesarch" data-bs-toggle="dropdown" aria-expanded="false" placeholder="Search for a term ">
<div class="col dropdown-menu form-control" aria-labelledby="inputSearch">
<div id="search_list_container">
<ul class="list-group" id="inputSearchEntries">
<li><a class="dropdown-item" href="#">First result</a></li>
<li><a class="dropdown-item" href="#">Another result</a></li>
<li><a class="dropdown-item" href="#">Some other result</a></li>
</ul>
</div>
<div id="doneSearchButton" class="d-flex justify-content-end">
<button type="submit" class="btn btn-primary">Done</button>
</div>
</div>
</div>
We have a custom eCommerce website and below is the code for the categories list which is a drop-down menu.
<div id="nav-header" class="nav-header navbar-default">
<div class="container ">
<div class="row">
<nav class="ms-mb-0" role="navigation">
<div class="col-sm-3 col-md-3">
<!--navheader sidebar categories on home page-->
<div class=" hover-dropdown dropdown vertical-megamenu navheader-sidebar-category ">
<div class="ms-br-zero dropdown-toggle btn-primary" type="button"
id="dropdownMenu1" data-toggle="dropdown">
<div id="menu-icon">
{{'SHOP BY CATEGORIES'|msTranslate}}
<i class="fa fa-bars pull-right ms-pt-xs"></i>
</div>
</div>
<ul
class="list-group nav-ul-color dropdown-menu ms-br-zero ms-br-none ms-pt-0 ms-pb-0 ms-mt-0 ms-w-full ms-z-index20 ms-pos-absolute"
role="menu" aria-labelledby="dropdownMenu1" aria-expanded="true"
data-ng-init="show={}">
<li class="list-group-item ms-br-zero level1" role="presentation "
data-ng-repeat="category in navigation.header.links">
<a href="{{category.url}}" class="ms-p-0 ms-ws-normal"
title="{{category.title|msTranslate}}">
{{category.title}}
<span data-ng-if="category.children.length ">
<i class="fa fa-angle-right pull-right">
</i>
</span>
</a>
<ul ng-if="category.children.length" class="list-unstyled level2 vertical"
ng-style="{'column-count':{{getcount(category)}}}">
<div class=" ms-p-xs dropdownMenu-lvl2">
<div class="dropdownMenu-lvl3 ms-pr-xs ms-lh-25 ms-mb-s "
ng-repeat="subcategory in category.children">
<a href="{{subcategory.url}}"
title="{{subcategory.title|msTranslate}}">
{{subcategory.title}}
<i ng-if="subcategory.children.length"
class="fa fa-caret-left">
</i>
</a>
<ul class="list-unstyled level3"
ng-if="subcategory.children.length">
<li ng-repeat="subcategory2 in subcategory.children"
class="subcategory2 ">
<a href="{{subcategory2.url}}"
title="{{subcategory2.title}}"
class="level3-links ">
{{subcategory2.title}}
</a>
</li>
</ul>
</div>
</div>
</ul>
</li>
<li class="list-group-item ms-br-zero level1" role="presentation ">
<a href="/allcategories" class="ms-p-0 ms-ws-normal"
title="{{'SEE ALL CATEGORIES'|msTranslate}}">
{{'SEE ALL CATEGORIES'|msTranslate}}
</a>
</li>
</ul>
</div>
</div>
If the language is English, subcategories show on the right side which is perfect as below:
But if the language is Arabic, subcategories show on the right side which is wrong because it is overflowing from the screen:
For Arabic, the menu should show on the left side of the screen.
I tried the following in the custom CSS but still the menu in Arabic doesn't show on the left side:
body .dropdownMenu1.dropdownMenu-lvl2,
body .dropdownMenu-lvl2.dropdownMenu-lvl3 {left:-250px !important;}
How to correct the code so that the menus in Arabic show on the left side.
I'm trying to get a card to be vertically centered between the search bar and the bottom of the viewport.
I've tried to make the body height 100%, but then it extends past the viewport and the user is able to scroll down into whitespace. I've tried to use align-content: center; on the parent container, but it doesn't change anything.
html.html
<body>
<div class="navbar navbar-expand-lg sticky-top">
<!-- nav info -->
</div>
<div class="container-fluid">
<!-- Title above search bar -->
<div class="row">
<div id="search-title" class="col-xl-6 col-md-7 col-sm-8 col-8 mx-auto">
<h3>Title</h3>
</div>
</div>
<!-- Search bar -->
<div class="row">
<div class="col-xl-6 col-md-7 col-sm-8 col-8 mx-auto">
<!-- search form -->
</form>
</div>
</div>
<!-- No results -->
<div class="row">
<div id="no-results" class="col-xl-6 col-md-7 col-sm-8 col-8 mx-auto">
{% if term != '' and not cameras %}
<!-- if no results then tell user -->
{% endif %}
</div>
</div>
<!-- Resulting card from search -->
{% if camera %}
<div class="container align-center">
<!-- I would like this card to be vertically centered between the search bar and the bottom of viewport -->
<div class="col-xl-6 col-md-7 col-sm-8 col-8 mx-auto card myclass">
<div class="card-body">
<!-- info -->
</div>
</div>
</div>
{% endif %}
</div>
</body>
css
html, body {
height: 100%;
width: 100%;
}
.align-center {
align-content: center;
}
This is what it looks like right now. Notice how the border on the body is below the viewport.
You can wrap your card element inside a container(card-container) with position property set to relative. Give your card absolute positioning with top property set to 50%. Make sure your container has a height property specified.
Edit 2:
You can also use the flex-box feature of css to make your layout more reponsive. It will also resolve the issue that you are having on big screen. I have update the code inside the container and css classes applied to container section. Update your code accordingly and let me know.
.card-container {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
border: 2px solid red;
}
.card-body {
flex: 2 0;
align-self: center;
border: 2px solid green;
}
.card {
flex: 1 1;
align-self: center;
}
.good-status {
color: #45A163;
}
.bad-status {
color: red;
}
<div class="card-container">
<div class="card mx-auto"></div>
<div class="card-body">
<h5 class="card-title text-center">Title</h5>
<ul>
<li>Item 1</li>
<li>Item 1</li>
<li>Item 1</li>
<li>Item 1</li>
</ul>
Ping device
Go to webbooter page
</div>
<div class="card mx-auto"></div>
</div>
</div>
You can do this by setting up your page height. Actually height:100vh fills the page completely. As you have the navbar, calc the height of it and subtract it from 100vh in this way height:calc(100vh - (56px)).
To set your card to the center of the page, you can use position:absolute and transform:translate(-50%,-50%) property. It will align your card to the vertical and horizontal center. I will be aligned to center in all the devices too.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css"
integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<style>
.form-control-borderless {
border: none;
}
.form-control-borderless:hover,
.form-control-borderless:active,
.form-control-borderless:focus {
border: none;
outline: none;
box-shadow: none;
}
.centre{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%)
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg bg-dark navbar-dark sticky-top">
<a class="navbar-brand" href="#"><img class="img-responsive" src="/testing/users/images/logo.png"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><span class="fa fa-fw fa-home"></span> Home</li>
<li class="nav-item"><a href="/testing/users/account.php" class="nav-link"><span
class="fa fa-fw fa-user"></span> admin</a></li>
<li class="nav-item">
<a href="/testing/users/messages.php" class="nav-link">
<span class="fa fa-envelope"></span><i class="badge"></i> Message</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown_main" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span class="fa fa-fw fa-cogs"></span> <span class="caret"></span>Settings</a>
<div class="dropdown-menu dropdown-info" aria-labelledby="dropdown_main">
<a class="dropdown-item" href="/testing/"><span class="fa fa-fw fa-home"></span> Home</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/testing/users/account.php"><span class="fa fa-fw fa-user"></span>
Account</a>
<a class="dropdown-item" href="/testing/users/admin.php"><span class="fa fa-fw fa-cogs"></span> Admin
Dashboard</a>
<a class="dropdown-item" href="/testing/users/admin.php?view=users"><span class="fa fa-fw fa-user"></span>
User Management</a>
<a class="dropdown-item" href="/testing/users/admin.php?view=permissions"><span
class="fa fa-fw fa-lock"></span> Permissions Management</a>
<a class="dropdown-item" href="/testing/users/admin.php?view=pages"><span class="fa fa-fw fa-wrench"></span>
Page Management</a>
<a class="dropdown-item" href="/testing/users/admin.php?view=messages"><span
class="fa fa-fw fa-envelope"></span> Messages Manager</a>
<a class="dropdown-item" href="/testing/users/admin.php?view=logs"><span class="fa fa-fw fa-search"></span>
System Logs</a>
<a class="dropdown-item" href="/testing/users/logout.php"><span class="fa fa-fw fa-sign-out"></span>
Logout</a>
</div>
</li>
<li class="nav-item dropdown menu">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<span class="fa fa-fw fa-lock"></span> menu
</a>
<div class="dropdown-menu w-100" aria-labelledby="navbarDropdown">
<a class="dropdown-item mx-auto" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Another action</a>
</div>
</li>
</ul>
</div>
</nav>
<div class="container" style="height:calc(100vh - (56px))">
<br>
<div class="row justify-content-center">
<div class="col-12 col-md-10 col-lg-8">
<form class="card card-sm">
<div class="card-body row no-gutters align-items-center">
<div class="col-auto">
<i class="fas fa-search h4 text-body"></i>
</div>
<div class="col">
<input class="form-control form-control-lg form-control-borderless" type="search"
placeholder="Search topics or keywords">
</div>
<div class="col-auto">
<button class="btn btn-lg btn-success" type="submit">Search</button>
</div>
<!--end of col-->
</div>
</form>
</div>
<!--end of col-->
</div>
<div class="col-sm-6 centre">
<div class="card bg-light ">
<div class="card-body text-center">
<p class="card-text">Some text inside the card</p>
</div>
</div>
</div>
</div>
</body>
</html>
There's no reason to use height:100%, calc() or extra CSS. Use the flexbox classes available in Bootstrap 4. Set a min height on the body (min-vh-100), flex direction column, and then flex-fill to allow the container to fill the remaining height. The vertical centering will then work as expected.
<body class="d-flex flex-column min-vh-100">
<nav>
</nav>
<div class="container-fluid d-flex flex-column flex-fill align-items-center justify-content-center">
<div class="row">...</div>
</div>
</body>
https://www.codeply.com/go/3k7MBc10tb
Related: Bootstrap 4: How to make the row stretch remaining height?
I have the following code section and I'm trying to put the badge on the rightmost part of the list-item, but somehow it keeps staying next to the text whatever I use ( style="float: right;" / class="pull-righ" / class="float-righ")
<div class="row" style="margin-top: 30px;">
<div class="col-2">
<ul class="list-group">
<li class="list-group-item active"><h4>Groups</h4></li>
#foreach($project->groups()->get() as $key=>$group)
<li class="list-group-item list-group-item-action" id="{{$group->name}}">{{$group->name}}<span class="badge badge-default pull-right"> {{$group->jobs()->count()}}</span></li>
#endforeach
</ul>
</div>
</div>
DEMO: https://jsfiddle.net/v4udh4Lc/7/
How can I float a fontawesome icon to the right and still have it vertically middle aligned? I've tried using ml-auto and Flexbox, but it's not working.
Here's my code:
<ul class="list-group flex-column">
<li class="list-group-item py-2 d-flex justify-content-start">
<a href="#">
<img src="https://placehold.it/40x40" height="40" class="mr-4">
<span>Text Here</span>
<i class="fa fa-angle-right ml-auto" aria-hidden="true"></i>
</a>
</li>
</ul>
Can someone help me out? Thanks!
Use the flex and sizing helper classes to make the link a flex parent with 2 children - the content you want on the left, and the content on the right. Use .justify-content-between, .align-items-center to separate the content so the arrow is on the right and centered vertically.
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="list-group flex-column">
<li class="list-group-item py-2 d-flex">
<a href="#" class="d-flex w-100 justify-content-between align-items-center">
<span>
<img src="https://placehold.it/40x40" height="40" class="mr-4">
<span>Text Here</span>
</span>
<i class="fa fa-angle-right ml-auto" aria-hidden="true"></i>
</a>
</li>
</ul>
Try with this structure:
<ul class="list-group">
<li class="list-group-item">
<a class="w-100 d-flex align-items-center py-2" href="#">
<img src="https://placehold.it/40x40" height="40" class="mr-4">
<span>Text Here</span>
<i class="fa fa-angle-right ml-auto" aria-hidden="true"></i>
</a>
</li>
</ul>
Click here to see it working in jsfiddle.
Your <a> tag doesn't fill the entire parent, so you can't see the effect of ml-auto on the icon. Also d-flex must be in the a tag, not in li.