Overlap div with sidebar without move div elements/div position - html

I try to develop a sidebar that opens on hover.
My problem is that when the sidebar is opened, the div with the content changes its position.
Is there any way to open and close the sidebar and keep the same placement of the text div?
DEMO
HTML
<div class="row rowSide" id="body-row">
<div [ngClass]="{'mySideBar': isSidebarCollapsed == false, 'mySideBar1': isSidebarCollapsed == true}"
(mouseenter)="hover()" (mouseleave)="hover1()" id="sidebar-container" class="sidebar-expanded d-md-block">
<ul class="list-group">
<a href="#" class="bg-dark list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-start align-items-center">
<span class="fa fa-tasks fa-fw mr-3"></span>
<span *ngIf="isSidebarCollapsed == false" class="menu-collapsed">Tasks</span>
</div>
</a>
<a href="#" class="bg-dark list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-start align-items-center">
<span class="fa fa-calendar fa-fw mr-3"></span>
<span *ngIf="isSidebarCollapsed == false" class="menu-collapsed textCollapsed">Calendar</span>
</div>
</a>
<a href="#top" data-toggle="sidebar-colapse" (click)="collapseSidebar()"
class="bg-dark list-group-item list-group-item-action d-flex align-items-center">
<div class="d-flex w-100 justify-content-start align-items-center">
<span id="collapse-icon" class="fa fa-2x mr-3"></span>
<span *ngIf="isSidebarCollapsed == false" id="collapse-text" class="menu-collapsed textCollapsed">Collapse</span>
</div>
</a>
</ul><!-- List Group END-->
</div><!-- sidebar-container END -->
<!-- MAIN -->
<div class="col p-4">
<h1 class="display-4">Collapsing Sidebar Menu</h1>
<div class="card">
<h5 class="card-header font-weight-light">Requirements</h5>
<div class="card-body">
<ul>
<li>JQuery</li>
<li>Bootstrap 4.3</li>
<li>FontAwesome</li>
</ul>
</div>
</div>
</div><!-- Main Col END -->
</div><!-- body-row END -->
.TS
public isSidebarCollapsed;
constructor() {
this.isSidebarCollapsed = false;
}
public collapseSidebar() {
this.isSidebarCollapsed = true;
}
hover(){
this.isSidebarCollapsed = false;
}
hover1(){
this.isSidebarCollapsed = true;
}
Problem: When the sidebar is open, the text div must maintain the same placement as when the sidebar is closed.

You probably don't need to change position prop of sidebar. Make it always fixed and move your content div with margin like this:
#body-row {
margin-left:60px;
margin-right:0;
}
#sidebar-container {
position: fixed;
left: 0;
min-height: 100vh;
background-color: #333;
padding: 0;
}

Related

Bootstrap 5 Vertical Alignment issue with responsive

I have a issue with vertical alignment in a container. I have the following code that does what I want, that is, the first row in the center and the second at the bottom of the container.
Full screen
<header class="masthead" id="home">
<div class="container h-100">
<div class="row h-100 align-items-center justify-content-evenly text-center">
<div class="col-4">
<img src="assets/img/profil.png" class="rounded-circle img-fluid" alt="...">
<hr class="divider" />
<h1 class="text-white font-weight-bold">d3vyce</h1>
</div>
<div class="col-md-8 col-lg-4">
<h2 class="text-white font-weight-bold">Hi 👋, Welcome to my Site!</h2>
<p class="text-white">Developer, CTF Player, Homelab, 3D Printing</p>
<hr class="divider" />
<div class="d-grid col-6 mx-auto">
<a class="btn btn-outline-light btn-lg" href="https://blog.d3vyce.fr" target="_blank"><i class="fa fa-bookmark fa-lg"></i> Blog</a>
<a class="btn mt-2 btn-outline-light btn-lg" href="https://github.com/d3vyce" target="_blank"><i class="fa fa-github fa-lg"></i> Github</a>
</div>
</div>
</div>
<div class="row head-row justify-content-center">
<div class="col-12 mouse_scroll p-0">
<a href="#about">
<div class="mouse">
<div class="wheel"></div>
</div>
<div>
<span class="m_scroll_arrows unu"></span>
<span class="m_scroll_arrows doi"></span>
<span class="m_scroll_arrows trei"></span>
</div>
</a>
</div>
</div>
</div>
</header>
For the alignment at the bottom of the second row I use the following CSS:
.mouse_scroll {
display: block;
width: 24px;
height: 100px;
position: absolute;
bottom: 0; }
The problem happens with the responsive. The columns of the first row are well one on top of the other, but the space between the two is much too important and I can't modify it :(
I tried to search on stackoverflow for answers, but after many tests I'm in a dead end...
Reponsive
Thank you in advance for your answers!

How can i put the <hr> closer with the content in header?

I want to put the <hr closer to the content in the header.
I try to use position-absolute but the disappears.
This is my first project with bootstrap.
<!-- Bootstrap-5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!--Body -->
<header class="header row">
<div class="d-flex justify-content-between">
<div id="logo" class="pb-2 ps-2 pe-0 col-2">
<img class="float-start py-2 ps-2 pe-2" src="assets/img/unknown.png">
<a href="#" class="sidebar-toggler flex-shrink-0" id="menu-toggle">
<i class="fa-solid fa-angle-left py-4 pe-2"></i>
</a>
</div>
<div class="col-10 row">
<h2 class="col-9 px-0 text-primary d-flex align-items-center">CHƯƠNG TRÌNH REBATE</h2>
<div class="col-3 px-0">
<div class="float-end d-flex justify-content-between">
<i class="fa fa-bell me-lg-2 d-flex align-items-center"></i>
<div class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown">
<img class="rounded-circle " src="assets/img/aTu.png" alt="" style="width: 40px; height: 40px;">
<span class="d-none d-lg-inline-flex text-primary">TuNTC23</span>
</a>
<div class="dropdown-menu bg-transparent border-0">
My Profile
Settings
Log Out
</div>
</div>
</div>
</div>
</div>
</div>
<hr style="height:1px;color:#1968B2;">
</header>
<hr style="height:1px;color:#1968B2; margin-top: -4px">
you can adjust the margin top according to your usage
I suggest you do not use the <hr> tag but a new css class or ::after to do that.
<header class="header row hr-bottom">
.hr-bottom {
border-bottom: 1px solid black;
}
OR
.hr-bottom::after {
border-bottom: 1px solid black;
}
The fastest way add class to hr for example bar
<hr class="bar" style="height:1px;color:#1968B2;">
and in CSS add class:
.bar {
transform: translateY(-10px);
}
Values up to you It may take px or procentage

Side Navbar with custom design

Imagen de un diseno en UPlabs
Hi im trying to make a navbar like this but i cant finish it.
someone can help me? Only want to know how round the border of links when they are active
Now i have this resolved, but i dont know how round borders on the container of the links like we see in the design of UpLabs
Image of my project
HTML
<div id="navbar" class="sticky-top">
<div class="d-flex flex-wrap justify-content-center align-content-center" style="height: 20%;">
<img class="{{url}}" alt="">
</div>
<nav class="nav flex-column ml-4">
<a id="link" routerLink="sales" routerLinkActive="active" class="nav-link font-weight-bold">
<div class="row">
<div class="col-3 p-0 text-right">
<i class="fas fa-cash-register"></i>
</div>
<div class="col-9">
Ventas
</div>
</div>
</a>
<a id="link" routerLink="debtors" routerLinkActive="active" class="nav-link font-weight-bold">
<div class="row">
<div class="col-3 p-0 text-right">
<i class="fas fa-user-friends"></i>
</div>
<div class="col-9">
Deudores
</div>
</div>
</a>
<a id="link" routerLink="balance" routerLinkActive="active" class="nav-link font-weight-bold">
<div class="row">
<div class="col-3 p-0 text-right">
<i class="fas fa-chart-line"></i>
</div>
<div class="col-9">
Balance
</div>
</div>
</a>
<a id="link" routerLink="products" routerLinkActive="active" class="nav-link font-weight-bold">
<div class="row">
<div class="col-3 p-0 text-right">
<i class="fas fa-boxes"></i>
</div>
<div class="col-9">
Productos
</div>
</div>
</a>
</nav>
</div>
and this is the file CSS that round borders of links when they are active and other parts of desing.
div#navbar {
left: 0px;
width: 100%;
height: 100vh;
border-radius: 0 40px 40px 0;
background: #f4755f;
}
a#link {
font-size: 18px;
padding: 20px 0;
color: white;
}
.active {
background: #fbf3f2;
color: #f4755f !important;
border-radius: 30px 0 0 30px;
}
img {
width: 45%;
height: 70%;
}
Making the border of a link round is done like that:
html:
Link 1
css
a {
background: red;
border-radius: 10px 0px 0 10px;
}
To make it round only when it is active you need to add a class to the active link and style that instead of the a tag, though.

Full width of col-md-10 when using col-md-2 for sidebar bootstrap 4

I am trying to add background color for nav-header, and since it is within col-md-10, it won't take full width when sidebar (col-md-2) is closed.
I tried to wrap it inside another div, but it doesn't work, I can't override col-md-10 rules. Is there any way to do this?
<div class="container-fluid">
<div class="row d-flex d-md-block flex-nowrap wrapper">
<div class="col-md-2 float-left col-1 pl-0 pr-0 collapse width hidden" id="sidebar">
<div class="list-group border-0 card text-center text-md-left">
<i class="fa fa-film"></i> <span class="d-none d-md-inline">Item 2</span>
<i class="fa fa-book"></i> <span class="d-none d-md-inline">Item 3 </span><i class="fa fa-heart"></i> <span class="d-none d-md-inline">Item 4</span>
<i class="fa fa-list"></i> <span class="d-none d-md-inline">Item 5</span>
</div>
</div>
<main class="col-md-10 float-left">
<div class="nav-header">
<i class="fa fa-navicon fa-2x py-2 p-1"></i>
<img src="img/logo.png" height="45" alt="">
</div>
<div class="page-header">
<h2>Bootstrap 4 Sidebar Menu</h2>
</div>
<hr>
</main>
</div>
</div>
Perhaps a positioned pseudo-element to imitate a background.
.col-md-10 .nav-header{
position: relative;
}
.col-md-10 .nav-header::after {
content:"";
position: absolute;
top:0;
left:0;
height:100%;
background: red;
width:calc(100vw - 30px);
}
.col-md-10 .nav-header {
position: relative;
}
.col-md-10 .nav-header::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
background: red;
width: calc(100vw - 30px);
z-index: -1
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row d-flex d-md-block flex-nowrap wrapper">
<div class="col-md-2 float-left col-1 pl-0 pr-0 collapse width hidden" id="sidebar">
<div class="list-group border-0 card text-center text-md-left">
<i class="fa fa-film"></i> <span class="d-none d-md-inline">Item 2</span>
<i class="fa fa-book"></i> <span class="d-none d-md-inline">Item 3 </span><a href="#" class="list-group-item d-inline-block collapsed"
data-parent="#sidebar"><i class="fa fa-heart"></i> <span class="d-none d-md-inline">Item 4</span></a>
<i class="fa fa-list"></i> <span class="d-none d-md-inline">Item 5</span>
</div>
</div>
<main class="col-md-10 float-left">
<div class="nav-header">
Nav header content
<i class="fa fa-navicon fa-2x py-2 p-1"></i>
<img src="img/logo.png" height="45" alt="">
</div>
<div class="page-header">
<h2>Bootstrap 4 Sidebar Menu</h2>
</div>
<hr>
</main>
</div>
That's tricky. Unless you can use the sass functions to build your columns, you'll have to override the styles for that particular .col-md-10. Maybe something like this?
#sidebar:not(.show) + [class*=col-] {
-webkit-box-flex: 0;
-webkit-flex: 0 0 100%;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
Demo (Note: I'm using jsfiddle because stack snippets is blocking a part of bootstrap's js and failing to execute the part for opening or closing the menu)
Edit
For those curious, the SCSS way to do it would be to use a mixin
Your SCSS might look like this:
#sidebar + main {
#include make-col(12);
}
#sidebar.show + main {
#include make-col(10);
}

How the image comes on the top of the above row in one div

I am working on the footer. On the right side down -image is attached- I have an image with a responsive "subscribe" button. There is one dive with one general row.This general row consists of two different rows.
The first row includes two grids: col-lg-4 / col-lg-8 (white background)
The second one includes three grids:col-lg-4 / col-lg-4 / col-lg-4 (black background)
I want to put the image in the second row in the very right grid which comes on the top of the very right grid in the first row.
the problem is although the image is put in the second row but it appears in the first row ! I want to correct it as the pattern
<div class="container-fluid p0 hidden-xs hidden-sm" style="border: solid yellow">
<div class="row">
<div class="col-lg-12 col-md-12 ">
<div class="row pb+ pt+ footer-border ">
<div class="col-lg-12 col-md-12">
<div class="container">
<!-- brand starts -->
<div class="col-lg-4 col-md-4 hidden-xs pl0">
<a href="/">
<i class=" icon-famousLogo icon-color famous-large "></i>
</a>
</div>
<!-- brand ends -->
<!-- Social Sharing Start -->
<div class="col-lg-8 col-md-8 hidden-xs clearfix">
<div class="col-lg-5 col-md-5 col-offset-7 pt-">
<ul class="list-inline float-r">
<li>
<span class="follow-us pr">FOLLOW US</span>
</li>
<li>
<a href="https://www.facebook.com/famousmagazine">
<i class=" icon-facebook icon-color facebook pr "></i>
</a>
</li>
<li>
<a href="https://twitter.com/famousweekly ">
<i class=" icon-twitter icon-color twitt pr"></i>
</a>
</li>
<li>
<a href="https://www.instagram.com/famousweekly/ ">
<i class=" icon-instagram icon-color instagram"></i>
</a>
</li>
<!-- They are supposed to be add later after getting the right URL-->
<!--<li >
<a href="https://www.youtube.com">
<i class=" icon-youtube icon-color youtube"></i>
</a>
</li>
<li >
<a href="https://www.instagram.com" >
<i class=" icon-Pintrest icon-color pint"></i>
</a>
</li>
<li >
<a href="https:https://twitter.com" >
<i class=" icon-tumblr icon-color twitt"></i>
</a>
</li> -->
<!-- Hidden Social Sharing Ends-->
</ul>
</div>
</div>
<!-- Social Sharing Ends -->
</div>
</div>
</div>
<!-- Second Row / Footer Lists Starts -->
<div class="row hidden-xs hidden-sm">
<div class="col-lg-12 col-md-12 ">
<div class="bottomMenu-parent" >
<div class="container">
<div class="col-lg-4 col-md-4 pl0 pt+ pb+" >
<table class="footer-table">
<tr>
<td>ABOUT US</td>
<td class="pl++">CoNTACT US</td>
<tr>
<td>TERMS AND CONDITIONS</td>
<td class="pl++">ADVERTISE</td>
</tr>
<tr>
<td>PRIVACY POLICY</td>
</tr>
</table>
</div>
<!-- Sign up Starts -->
<div class="col-lg-4 col-md-4">
</div>
<!--Sign Up Ends -->
<div class="col-lg-4 col-md-4">
<figure class="p pb0 footer-image">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTPZA23BVynjg91p0lXTn2yEiCft5VkK70063kgELaL_77gtH_TWg">
</figure>
<a href="#" class="subscribe-button" >
<button type="button" >
SUBSCRIBE <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span>
</button>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- Second Row / Footer List Ends -->
</div>
</div>
</div>
#media(min-width: #screen-sm-min) {
.follow-us{
color:#mainpink;
.font-family(#font-Oswald-Bold) ;
font-size: 12px;
}
.footer-border{
border: 1px solid #mainpink;
}
.footer-table{
color:#white !important;
text-align: left;
tr{
td{
padding-bottom:10px;
a{
.font-family(#font-SourceSansPro-Regular) !important;
color:#white !important;
text-transform: uppercase;
font-size:14px;
}
}
}
}
.footer-image{
position: absolute;
bottom: 0px;
display: block;
width: 100%;
text-align: center;
}
}
I have changed the codes as below then it works :
.footer-image
{
margin-top: -100px;
bottom: 0px;
display: block;
width: 100%;
text-align: center;
padding-bottom:0px;
}