I have created a structure for a header and a sticky top navbar.
When we scroll down (medium screen and up), there is always a space line between my header and my navbar. We can see the body in that space.
Picture of the thin space line in yellow
I saw this come from the 3 buttons because when we deleted them, the space disapears but I don't know how to solve the problem.
Any idea ?
Please find my code
Thank you
SOLVED
The problem came from the a class bottom border. I think they didn't fit in the parent element.
Code after correction
HTML
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" />
<section>
<div class="container-fluid bg-danger">
<div class="row">
<div class="col-md-6 my-auto">
<a class="d-flex justify-content-center align-items-center" href="#">
<h1 class="text-center"><span class="ft-color-1">BRAND NAME</span></h1>
</a>
</div>
<div class="col-md-6 p-2">
<ul>
<li>Adress, city</li>
<li>Ouvert 7/7 de 7h à 21h</li>
</ul>
<div class="d-none d-md-flex flex-row mb-2">
<a class="btn p-1 mr-1 w-100 bg-primary text-left" href="" role="button"> Itinéraire</a>
<a class="btn p-1 mr-1 w-100 bg-primary text-left" href="" role="button"> Contact</a>
<a class="btn p-1 mr-0 w-100 bg-primary text-left" href="" role="button"> Suivez-nous</a>
</div>
</div>
</div>
</div>
</section>
<nav class="navbar navbar-expand-md sticky-top bg-primary" id="navigation-barre">
<a class="navbar-brand text-white" href="#"> Brand name</a>
</nav>
<section class="bg-warning">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</section>
Related
I am using the following to show a list horizontally or vertically depending on the screen size.
<div class="row">
<div class="col-md-3">
<div class="d-md-none">
<div class="card">
<div class="card-body p-0">
<ul class="list-group list-group-horizontal">
<li class="list-group-item border-0">
<a href="javascript: void(0);" #onclick="">
<i class="fas fa-search" />
</a>
</li>
<li class="list-group-item border-0">
<a href="javascript: void(0);" #onclick="">
<i class="fas fa-address-card" />
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="d-none d-md-block">
<!-- Here the list vertically !-->
</div>
</div>
<div class="col-md-9">
</div>
</div>
The problem is that when viewed on mobile devices, the card overflows out of its div. What can I change to make this not happen? Can I decrease the spacing between the items?
When I add the class float-end it pushes the button to right but the div tags next to that comes front of it.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="col-md-7 bg-white shadow-sm rounded-3 mx-3 ">
<div>
<a href="#" class="btn btn-sm btn-primary m-2 mr-0">
Edit <i class="bi bi-pencil"></i>
</a>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Pan no</div>
<div class="text-secondary">not added</div>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Birthdate</div>
<div class="text-secondary">not added</div>
</div>
</div>
I fixed it by adding the "clearfix" class to button's parent div.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="col-md-7 bg-white shadow-sm rounded-3 mx-3 ">
<div class="clearfix">
<a href="#" class="btn btn-sm btn-primary m-2 mr-0">
Edit <i class="bi bi-pencil"></i>
</a>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Pan no</div>
<div class="text-secondary">not added</div>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Birthdate</div>
<div class="text-secondary">not added</div>
</div>
</div>
Here, in the overview section
Float - Bootstrap v5.0
Please be aware float utilities have no effect on flex items.
Note that float will will make it pop to the left-most or right-most position in the parent element. so you must add clearfix to the parent element.
Hello I have two options for you
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- one options -->
<div class="col-md-7 bg-white shadow-sm rounded-3 mx-3 ">
<div class="position-relative">
<div class="position-absolute top-0 end-0">
<a href="#" class="btn btn-sm btn-primary m-2 mr-0">
Edit
</a>
</div>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Pan no</div>
<div class="text-secondary">not added</div>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Birthdate</div>
<div class="text-secondary">not added</div>
</div>
</div>
<br>
<!-- two options -->
<br>
<div class="col-md-7 bg-white shadow-sm rounded-3 mx-3 ">
<div class="float-start col-10 p-2">
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Pan no</div>
<div class="text-secondary">not added</div>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Birthdate</div>
<div class="text-secondary">not added</div>
</div>
</div>
<div class="float-end col-2 p-2">
<a href="#" class="btn btn-sm btn-primary d-flex justify-content-center align-self-center">
Edit
</a>
</div>
<div class="float-start col-12 p-2">
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Addres</div>
<div class="text-secondary">not added</div>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">Zip Code</div>
<div class="text-secondary">not added</div>
</div>
<div class="d-flex p-2 justify-content-between border-bottom">
<div class="fw-bold">City</div>
<div class="text-secondary">not added</div>
</div>
</div>
</div>
I have a problem:
as you can see in the picture, the problem is, that the column doesnt take the full hight. On the left side is what i got and on the right is what i want. Maybe you guys can help me out. Here is the source code which leads to the image on the left. I have searched for a solution but unfortunatelly nothing fits my source code.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<div>
<div class="row m-auto">
<div class="col-md-12 p-0">
<div>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">
Navbar w/ text
</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarText"
aria-controls="navbarText"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">
Home <span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
Features
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
Pricing
</a>
</li>
</ul>
<span class="navbar-text">Navbar text with an inline element</span>
</div>
</nav>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-4 bg-warning">
<!-- this is the left side -->
<div>
<div class="row m-1">
<div class="col-md-11">
Chats
</div>
<div class="col-md-1">
<i class="fas fa-plus-circle"></i>
</div>
</div>
<div class="row mb-2">
<div class="col-md-12">
<form class="form-inline" style={{ height: "0%", width: "100%", paddingLeft: "0", paddingRight: "0", paddingTop: "8px" }}>
<input class="form-control mr-sm-1" style={{ width: "80%" }} type="search" placeholder="Suchen" aria-label="Search" />
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Suchen</button>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="list-group">
<div>
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start" style={{marginTop: "7.5px", marginBottom: "7.5px"}}>
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">List group item heading</h5>
<small>3 days ago</small>
</div>
<div class="row">
<div class="col-md-11">Donec id elit non mi porta...
</div>
<div class="col-md-1">
<span class="badge badge-primary badge-pill text-right">5</span>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-8 bg-primary">
<div>
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
<div class="row">
<!-- it should be the full width but unfortunatelly a scrollbar appears because of this section right here... -->
<div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">
<img src="..." class="image-head-chat" alt="Responsive image" />
</div>
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8">
Text
</div>
<div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">
Icons
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
<!-- Should be in the middle and full screen (like the area where you and another person have a conversation-->
Message
</div>
</div>
<div class="row">
<!-- should be at the bottom of the Screen like in everyother Chat-->
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
Text-Input and Button
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
This question is basically the same as this and this, but the overly complex, nested and incorrect Bootstrap grid structure you're using make it almost impossible to make the height work as expected.
If you simplify the markup as recommended in your other questions, the height issue is resolved using the flexbox grow and shrink utilities as explained in the Bootstrap docs...
"Use .flex-grow-* utilities to toggle a flex item’s ability to grow to
fill available space. "
Using vh-100, flex-grow-0, flex-grow-1, flex-column, etc...
<div class="container-fluid d-flex flex-column vh-100">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
...
</nav>
<div class="row flex-grow-1">
<div class="col-md-4 bg-warning">
<!-- this is the left side -->
</div>
<div class="col-md-8 bg-primary d-flex flex-column flex-grow-1">
<div class="row flex-column flex-fill">
<div class="col bg-success flex-grow-0">
<div class="row">
<!-- it should be the full width but unfortunatelly a scrollbar appears because of this section right here... -->
</div>
</div>
<div class="col bg-info flex-fill">
<!-- Should be in the middle and full screen (like the area where you and another person have a conversation--> Message </div>
<!-- should be at the bottom of the Screen like in everyother Chat-->
<div class="col bg-success flex-grow-0"> Text-Input and Button </div>
</div>
</div>
</div>
</div>
https://codeply.com/p/iP18GJ1ZdU
It can be done through display: flex. It is necessary to set height: 100% to take available height.
So I've edited some classes and add some classes.
The complete stackblitz example can be seen here
An example:
<div class="box">
<div class="row box m-0">
<div class="col-md-12 p-0 foo-flex">
<div>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">
Navbar w/ text
</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarText"
aria-controls="navbarText"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">
Home <span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
Features
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
Pricing
</a>
</li>
</ul>
<span class="navbar-text">Navbar text with an inline element</span>
</div>
</nav>
</div>
<div class="container-fluid foo-flex-item">
<div class="row h-100">
<div class="col-md-4 bg-warning">
<div>
<div class="row m-1">
<div class="col-md-11">
Chats
</div>
<div class="col-md-1">
<i class="fas fa-plus-circle"></i>
</div>
</div>
<div class="row mb-2">
<div class="col-md-12">
<form class="form-inline" style="height: 0%; width: 100%; paddingLeft: 0; paddingRight: 0; paddingTop: 8px;">
<input class="form-control mr-sm-1" style="width: 80%;" type="search" placeholder="Suchen" aria-label="Search" />
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Suchen</button>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="list-group">
<div>
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start" style="7.5px; marginBottom: 7.5px;">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">List group item heading</h5>
<small>3 days ago</small>
</div>
<div class="row">
<div class="col-md-11">Donec id elit non mi porta...
</div>
<div class="col-md-1">
<span class="badge badge-primary badge-pill text-right">5</span>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-8 bg-primary">
<div>
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
<div class="row">
<div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">
<img src="..." class="image-head-chat" alt="Responsive image" />
</div>
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8">
Text
</div>
<div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">
Icons
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
Message
</div>
</div>
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
Text-Input and Button
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- <script src=" index.js"></script> -->
<link rel="stylesheet" type="text/css"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js">
</script>
I am using Angular 7 + Bootstrap. I am using bootstrap card deck to create 3 menus.
When the routerlinkactive is active, I want to style the border for that particular card, where the link is available.
<div class="container-fluid">
<div class="card-deck mb-3 text-center">
<div class="card mb-4 box-shadow"> <!-- want to style at this level when link is active -->
<div class="card-header pb-2">
<h4 class="my-0 font-weight-normal">Menu 1</h4>
</div>
<div class="card-body">
<a routerLinkActive="active" routerLink='my-courses' class="link-unstyled">
<i class="fas fa-tasks fa-9x"></i></a>
</div>
</div>
<div class="card mb-4 box-shadow">
<div class="card-header pb-2">
<h4 class="my-0 font-weight-normal">Menu 2</h4>
</div>
<div class="card-body">
<a routerLinkActive="active" routerLink='completion-certs' class="link-unstyled">
<i class="fas fa-award fa-9x"></i></a>
</div>
</div>
<div class="card mb-4 box-shadow">
<div class="card-header pb-2">
<h4 class="my-0 font-weight-normal">Menu 3</h4>
</div>
<div class="card-body">
<a routerLinkActive="active" routerLink='self-certification' class="link-unstyled">
<i class="fas fa-book-reader fa-9x"></i></a>
</div>
</div>
</div>
</div>
You can use something like this.
<a #rla="routerLinkActive" routerLinkActive="active" routerLink='my-courses' class="link-unstyled">.... </a>
and on the card div you can use [class.active-card]="rla.isActive"
I want to achieve a layout like this:
But its not working properly, Im getting this: http://jsfiddle.net/9cfqjmkb/. The title should be aligned with the top of the image but its not working. Do you know why?
Also I want some margin between the image and the other div with the title and post date, as it is in the image above, but the margin is not working. Do you know why?
HTML
<div class="container">
<div class="row">
<div class="col-3">
<div class="bg-custom-light2 p-0">
<h2 class="font-weight-bold text-custom-blue-dark h5 border-color p-2">Title</h2>
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<h6 class="font-weight-bold text-custom-blue-dark">Test title example for
example test post</h6>
<p>post date date</p>
</div>
<img class="ml-2" src="https://via.placeholder.com/50" alt="">
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<h6 class="font-weight-bold text-custom-blue-dark">Test title example for
example test post</h6>
<p>post date date</p>
</div>
<img class="ml-2" src="https://via.placeholder.com/50" alt="">
</li>
</ul>
</div>
</div>
</div>
</div>
?
.list-group {
width:300px;
}
.ml-2 {
align-self:flex-start;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-3">
<div class="bg-custom-light2 p-0">
<h2 class="font-weight-bold text-custom-blue-dark h5 border-color p-2">Title</h2>
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<h6 class="font-weight-bold text-custom-blue-dark">Test title example for
example test post</h6>
<p>post date date</p>
</div>
<img class="ml-2" src="https://via.placeholder.com/50" alt="">
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<h6 class="font-weight-bold text-custom-blue-dark">Test title example for
example test post</h6>
<p>post date date</p>
</div>
<img class="ml-2" src="https://via.placeholder.com/50" alt="">
</li>
</ul>
</div>
</div>
</div>
</div>