So I am trying to achieve is that I have made a row and inside that row there are two columns first is a left_bar column and second column is large image so what I want is that when the screen hits medium breakpoint from medium to small screen I only have to show the large image i.e column 2 and not column 1 i.e the left_bar
I have also posting the required output from medium screen to small screen.
I am also mentioning my code snippet
body{
margin: 0;
padding: 0;
}
@media screen and (min-width: 300px) and (max-width: 500px){
}
@media screen and (min-width: 500px) and (max-width: 700px){
}
@media screen and (min-width: 700px) and (max-width: 900px){
}
@media screen and (min-width: 900px) and (max-width: 920px){
}
.left_bar{
height: 100vh;
background-color: #030C13;
margin: 0;
}
.hero_image{
width: 100%;
height: 100vh;
background-image: url('https://imaging.nikon.com/lineup/dslr/df/img/sample/img_01.jpg');
background-position: center;
background-position: right;
background-size: cover;
background-repeat: no-repeat;
}
.img-thumbnail{
border: none !important;
}
.profile_pic {
width: 150px;
height: 150px;
border-radius: 50%;
margin-top: 3em;
display: flex;
justify-content: center;
box-shadow: -1px 0px 0px 14px #262837
}
.name{
display: flex;
justify-content: center;
margin-top: 1em;
color: #FCFEFF;
}
.fb_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
margin-left: 1em;
}
.tw_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
}
.lg_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
margin-left: 1em;
}
.fa-twitter {
font-size: 20px;
left: 16px;
position: absolute;
top: 15px;
color: white;
cursor: pointer;
}
.fa-facebook-f {
font-size: 20px;
left: 19px;
position: absolute;
top: 15px;
color: white;
cursor: pointer;
}
.tw_div:hover{
background-color: white;
}
.tw_div:hover .fa-twitter{
color:black ;
}
.fb_div:hover{
background-color: white;
}
.fb_div:hover .fa-facebook-f{
color: black;
}
.lg_div:hover{
background-color: white;
}
.lg_div:hover .fa-instagram{
color: black;
}
.fa-instagram {
font-size: 24px;
left: 15px;
position: absolute;
top: 12px;
color: white;
cursor: pointer;
}
.fa-skype{
font-size: 24px;
left: 15px;
position: absolute;
top: 12px;
color: white;
cursor: pointer;
}
.fa-linkedin-in{
font-size: 24px;
left: 15px;
position: absolute;
top: 12px;
color: white;
cursor: pointer;
}
.sky_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
margin-left: 1em;
}
.sky_div:hover{
background-color:white ;
}
.sky_div:hover .fa-skype{
color: black;
}
.ld_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
margin-left: 1em;
}
.ld_div:hover{
background-color:white ;
}
.ld_div:hover .fa-linkedin-in{
color: black;
}
.nav_tabs{
display: flex;
}
.nav-link{
color: #92959D ;
margin-bottom: 1em
}
.nav-link:hover{
color: white;
}
.fa-home{
color: #377DB3;
font-size:1.5em;
}
.fa-user{
color: #5F656F;
font-size:1.5em;
}
.nav-link:hover .fa-user{
color: #377DB3;
}
.fa-file{
color: #5F656F;
font-size:1.5em;
}
.nav-link:hover .fa-file{
color: #377DB3;
}
.nav-link:hover .fa-list-alt{
color: #377DB3;
}
.fa-list-alt{
color:#5F656F ;
font-size:1.5em;
}
.nav-link:hover .fa-server{
color: #377DB3;
}
.fa-server{
color: #5F656F;
font-size:1.5em;
}
.nav-link:hover .fa-envelope{
color: #377DB3;
}
.fa-envelope{
color: #5F656F;
font-size:1.5em;
}
.nav-item a{
margin-left: 1em;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignment 8</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
</head>
<body>
<div >
<div >
<div >
<img src="https://imaging.nikon.com/lineup/dslr/df/img/sample/img_01.jpg" alt="...">
<h2 >Alex Smith</h2>
<div >
<div ><i ></i></div>
<div ><i ></i></div>
<div ><i ></i></div>
<div ><i ></i></div>
<div ><i ></i></div>
</div>
<div >
<ul >
<li >
<a aria-current="page" href="#"><i ></i><span >Home</span> </a>
</li>
<li >
<a href="#"><i ></i><span > About</span></a>
</li>
<li >
<a href="#"><i ></i><span > Resume</span> </a>
</li>
<li >
<a href="#"><i ></i><span >Portfolio</span> </a>
</li>
<li >
<a href="#"><i ></i><span >Services</span> </a>
</li>
<li >
<a href="#"><i ></i> <span >Contact</span></a>
</li>
</ul>
</div>
</div>
<div >
</div>
</div>
</div>
</body>
</html>
CodePudding user response:
To show/hide elements in BS5 you can use .d-{breakpoint}-{value} classes. The classes are applied from min-width: 0; and up.
So, you can set .d-block.d-md-none, which means to show block for mobile, and up to 'md' breakpoint (tablet and larger) - hidden.
And opposite: .d-none.d-md-block - will hide for mobile and show block for tablet and larger
body{
margin: 0;
padding: 0;
}
@media screen and (min-width: 300px) and (max-width: 500px){
}
@media screen and (min-width: 500px) and (max-width: 700px){
}
@media screen and (min-width: 700px) and (max-width: 900px){
}
@media screen and (min-width: 900px) and (max-width: 920px){
}
.left_bar{
height: 100vh;
background-color: #030C13;
margin: 0;
}
.hero_image{
width: 100%;
height: 100vh;
background-image: url('https://imaging.nikon.com/lineup/dslr/df/img/sample/img_01.jpg');
background-position: center;
background-position: right;
background-size: cover;
background-repeat: no-repeat;
}
.img-thumbnail{
border: none !important;
}
.profile_pic {
width: 150px;
height: 150px;
border-radius: 50%;
margin-top: 3em;
display: flex;
justify-content: center;
box-shadow: -1px 0px 0px 14px #262837
}
.name{
display: flex;
justify-content: center;
margin-top: 1em;
color: #FCFEFF;
}
.fb_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
margin-left: 1em;
}
.tw_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
}
.lg_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
margin-left: 1em;
}
.fa-twitter {
font-size: 20px;
left: 16px;
position: absolute;
top: 15px;
color: white;
cursor: pointer;
}
.fa-facebook-f {
font-size: 20px;
left: 19px;
position: absolute;
top: 15px;
color: white;
cursor: pointer;
}
.tw_div:hover{
background-color: white;
}
.tw_div:hover .fa-twitter{
color:black ;
}
.fb_div:hover{
background-color: white;
}
.fb_div:hover .fa-facebook-f{
color: black;
}
.lg_div:hover{
background-color: white;
}
.lg_div:hover .fa-instagram{
color: black;
}
.fa-instagram {
font-size: 24px;
left: 15px;
position: absolute;
top: 12px;
color: white;
cursor: pointer;
}
.fa-skype{
font-size: 24px;
left: 15px;
position: absolute;
top: 12px;
color: white;
cursor: pointer;
}
.fa-linkedin-in{
font-size: 24px;
left: 15px;
position: absolute;
top: 12px;
color: white;
cursor: pointer;
}
.sky_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
margin-left: 1em;
}
.sky_div:hover{
background-color:white ;
}
.sky_div:hover .fa-skype{
color: black;
}
.ld_div{
position: relative;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #1D212B;
padding: 1.5em;
margin-left: 1em;
}
.ld_div:hover{
background-color:white ;
}
.ld_div:hover .fa-linkedin-in{
color: black;
}
.nav_tabs{
display: flex;
}
.nav-link{
color: #92959D ;
margin-bottom: 1em
}
.nav-link:hover{
color: white;
}
.fa-home{
color: #377DB3;
font-size:1.5em;
}
.fa-user{
color: #5F656F;
font-size:1.5em;
}
.nav-link:hover .fa-user{
color: #377DB3;
}
.fa-file{
color: #5F656F;
font-size:1.5em;
}
.nav-link:hover .fa-file{
color: #377DB3;
}
.nav-link:hover .fa-list-alt{
color: #377DB3;
}
.fa-list-alt{
color:#5F656F ;
font-size:1.5em;
}
.nav-link:hover .fa-server{
color: #377DB3;
}
.fa-server{
color: #5F656F;
font-size:1.5em;
}
.nav-link:hover .fa-envelope{
color: #377DB3;
}
.fa-envelope{
color: #5F656F;
font-size:1.5em;
}
.nav-item a{
margin-left: 1em;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignment 8</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
</head>
<body>
<div >
<div >
<div >
<img src="https://imaging.nikon.com/lineup/dslr/df/img/sample/img_01.jpg" alt="...">
<h2 >Alex Smith</h2>
<div >
<div ><i ></i></div>
<div ><i ></i></div>
<div ><i ></i></div>
<div ><i ></i></div>
<div ><i ></i></div>
</div>
<div >
<ul >
<li >
<a aria-current="page" href="#"><i ></i><span >Home</span> </a>
</li>
<li >
<a href="#"><i ></i><span > About</span></a>
</li>
<li >
<a href="#"><i ></i><span > Resume</span> </a>
</li>
<li >
<a href="#"><i ></i><span >Portfolio</span> </a>
</li>
<li >
<a href="#"><i ></i><span >Services</span> </a>
</li>
<li >
<a href="#"><i ></i> <span >Contact</span></a>
</li>
</ul>
</div>
</div>
<div >
</div>
</div>
</div>
</body>
</html>
At this Code snippet, you can see, that when it's reduced (right after running) you can see "large" sunset image; If you enlarge it (open in full screen), you will see sidebar.
