For some reason, the bottom border on my button disappears on hover, and I have no idea why. It works perfectly locally, but when I check my site live it disappears.
Here is my Codepen https://codepen.io/ecanada138/pen/ExXRXoW, which is the exact code on my repo.
Here is the site https://8thvisionmedia.netlify.app/, where you can see the problem but it does not show up on CodePen or locally
#font-face {
font-family: cocogoose-regular;
src: url('../fonts/Cocogoose-Classic-Medium-trial.ttf');
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Montserrat', sans-serif;
}
body {
font-family: 'Open Sans', sans-serif;
line-height: 1.5;
}
.navbar-nav a {
list-style-type: none;
text-align: center;
display: inline-block;
margin: 0px;
padding: 0px 10px 0px 10px;
border-right: 1px solid rgb(255, 255, 255);
height: 20px;
}
.vimeo-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
/* pointer-events: none; */
overflow: hidden;
}
.vimeo-wrapper iframe {
width: 100vw;
height: 56.25vw;
/* Given a 16:9 aspect ratio, 9/16*100 = 56.25 */
min-height: 100vh;
min-width: 177.77vh;
/* Given a 16:9 aspect ratio, 16/9*100 = 177.77 */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
/* z-index: -1; */
}
.phone-nav {
display: none;
}
.navbar-nav {
display: flex;
flex-direction: column;
margin-top: 1rem;
color: rgb(255, 255, 255);
font-size: 1rem;
}
.navbar-toggler:focus {
text-decoration: none;
outline: 0;
box-shadow: 0 0 0 0.1rem;
border: 1px solid rgb(255, 255, 255);
}
.custom-toggler .navbar-toggler-icon {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,255,255, 1.0)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
}
.navbar-toggler:focus {
box-shadow: none;
}
.desktop-nav-container {
flex-direction: row;
justify-content: center;
}
/* .nav-link-desktop::after{
content: ' |';
} */
#media screen and (max-width: 992px) {
.phone-nav {
display: block;
}
}
.home-container {
height: 100vh;
z-index: 1000;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: rgb(255, 255, 255);
}
.home-row {
padding: 0 10rem 0 10rem;
z-index: 1000;
}
.home-text {
text-align: center;
font-size: 1.2rem;
letter-spacing: 3px;
}
.home-col {
width: 100%;
}
.col-logo {
position: absolute;
left: 2rem;
bottom: 1rem;
margin-bottom: 0.5rem;
padding: 0;
}
.row-copyright {
position: absolute;
right: 2rem;
bottom: 1rem;
font-family: 'Montserrat', sans-serif;
}
.vision-media-logo {
width: 3rem;
}
a {
color: rgb(255, 255, 255) !important;
font-size: 14px;
}
.fa {
font-size: 2rem;
}
ul {
text-align: center;
}
#media screen and (min-width: 1399px) {
.home-row {
padding: 0 20rem 0 20rem;
}
}
#media screen and (min-width: 1800px) {
.home-row {
padding: 0 35rem 0 35rem;
}
}
#media screen and (min-width: 2200px) {
.home-row {
padding: 0 50rem 0 50rem;
}
}
#media screen and (max-width: 767px) {
.navbar-nav {
margin-right: 0;
}
.home-row {
padding: 0 3rem 0 3rem;
}
}
#media screen and (max-width: 575px) {
.home-row {
padding: 0 1rem 0 1rem;
margin-top: -8rem;
}
.home-text {
font-size: 1rem;
}
.vision-media-logo {
width: 2rem;
}
.col-logo {
position: absolute;
left: 1rem;
bottom: 1rem;
}
.row-copyright {
position: absolute;
right: 1rem;
bottom: 0rem;
font-family: 'Montserrat', sans-serif;
font-size: 12px;
}
}
/* .myIcon {
margin-left: 3rem;
margin-right: 3rem;
}
.hide {
visibility: hidden;
font-size: 1rem;
margin-top: 10px;
opacity: 0;
text-transform: uppercase;
text-align: center;
transition: 0.8s;
}
.myIcon:hover .hide {
visibility: visible;
opacity: 1;
}
.myIcon {
z-index: 1000;
}
*/
#media screen and (max-width: 576px) {
.vimeo-wrapper {
background-image: url('../images/home-screen-bg.jpg');
background-position: center;
background-size: cover;
}
.vimeo-wrapper iframe {
display: none;
}
.phone-container {
position: relative;
}
}
#media screen and (max-width: 515px) {
.fa-col {
display: flex;
flex-direction: row;
}
}
#media screen and (min-width: 992px) {
.navbar-expand-lg .navbar-nav .nav-link {
padding-right: 0.75rem;
padding-left: 0.75rem;
}
.desktop-nav-container {
display: none !important;
}
}
.col-copyright {
margin-bottom: 1rem;
}
#media screen and (max-width: 992px) {
.navbar-nav a {
list-style-type: none;
text-align: center;
display: inline-block;
margin: 0px;
padding: 0.5rem 1rem;
border: none;
height: 100%;
font-size: 1rem;
}
}
.create-button {
background-color: rgba(255, 255, 255, 0);
color: rgb(255, 255, 255);
outline: 0;
border: 1px solid rgb(255, 255, 255) !important;
border-bottom: 1px solid rgb(255, 255, 255) !important;
font-family: 'cocogoose-regular';
letter-spacing: 2px;
margin: auto;
padding: 1rem 2rem;
text-align: center;
text-decoration: none;
transition: 0.5s ease;
}
.create-button a {
text-decoration: none;
}
.create-button:hover {
background-color: rgba(255, 255, 255, 0.3);
/* color: rgb(255, 255, 255); */
/* outline: 0; */
/* border: 1px solid rgb(255, 255, 255); */
/* font-family: 'cocogoose-regular'; */
/* letter-spacing: 2px; */
/* width: 100%; */
/* padding: 1rem 2rem; */
transform: scale(1.1);
}
<!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" />
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous" />
<!-- Font Awesome -->
<script src="https://kit.fontawesome.com/5826f42d14.js" crossorigin="anonymous"></script>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght#400&display=swap" rel="stylesheet" />
<!-- CSS SHEETS -->
<link rel="stylesheet" href="css/index.css" />
<title>8th Vision Media | Real Estate Video and Photo Production</title>
<link rel="shortcut icon" type="image/png" href="./images/8-vision-logo-favicon.ico" />
</head>
<body>
<!--------------------------------------- NAV BAR --------------------------------------------------->
<div class="phone-container">
<nav class="navbar navbar-expand-xxxxxxl phone-nav">
<div class="container-fluid">
<button class="navbar-toggler custom-toggler ms-auto" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-column align-items-end" id="navbarNav">
<ul class="navbar-nav flex-column">
<!-- <li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li> -->
<li class="nav-item">
<a class="nav-link" href="./gallery.html">Video Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./core-values.html">Core Values </a>
</li>
<li class="nav-item">
<a class="nav-link" href="./contact.html">Get In Touch</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" href="./our-people.html">Our People</a>
</li> -->
<li class="nav-item">
<a class="nav-link" target="_blank" href="https://www.instagram.com/8thvisionmedia/">Our Work</a
>
</li>
</ul>
</div>
</div>
</nav>
<nav class="navbar navbar-expand-lg desktop-nav">
<div class="container-fluid">
<div
class="collapse navbar-collapse desktop-nav-container"
id="navbarNavAltMarkup"
>
<div class="navbar-nav">
<a
class="nav-link nav-link-desktop"
aria-current="page"
href="./contact.html"
>Get In Touch</a
>
<a class="nav-link nav-link-desktop" href="./core-values.html"
>Core Values
</a>
<a class="nav-link nav-link-desktop" href="./gallery.html">Video Gallery</a
>
<a
style="border-right: none; text-decoration: none"
target="_blank"
href="https://www.instagram.com/8thvisionmedia/"
>Our Work</a
>
</div>
</div>
</div>
</nav>
<div class="vimeo-wrapper">
<iframe
src="https://player.vimeo.com/video/570788340?background=1&autoplay=1&loop=1&byline=0&title=0"
frameborder="0"
webkitallowfullscreen
mozallowfullscreen
allowfullscreen
></iframe>
<div>
<div class="container-fluid home-container">
<div class="row home-row">
<div class="col home-col">
<!-- <p class="home-text">
We create powerful visual content for brands that help drive
sales, growth and engagement.
</p> -->
<button
onClick="window.open('https://www.8thvisionmedia.com/contact');"
class="create-button"
>
<a
href="./contact.html
"
>CREATE WITH US
</a>
</button>
</div>
</div>
<!-- <div class="row fa-row text-center">
<div class="col fa-col">
<span>
<a
href="https://www.instagram.com/8thvisionmedia/"
target="_blank"
><i class="myIcon fab fa-instagram fa-2x"
><p class="hide">What We Do</p></i
></a
></span
><span
><a href="mailto:create#8thvisionmedia.com"
><i class="myIcon far fa-envelope fa-2x"
><p class="hide">Take Your Next Step</p></i
></a
>
</span>
</div>
</div> -->
<div class="row row-logo">
<div class="col col-logo">
<img class="vision-media-logo" src="./images/8th-vision-logo.png" />
</div>
</div>
<div class="row row-copyright">
<div class="col col-copyright">
<a>© 2021 8th Vision Media</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
</body>
</html>
remove transform: scale(1.1);
it worked
It worked fine on firefox. But I saw the issue on edge. and solved it by adding padding to .home-col class.
add the following and it should work fine:
.home-col {
padding: 10px;
}
I dont know exactly the reason, but changing "scale" value will solve the problem :
transform: scale(1.2); for example
Related
I have nav elements with a hamburger menu which is hidden at desktop screen size but when I get to tablet and mobile, I want this nav elements to be hidden and the hamburger menu to show but it is not working. I am using sass btw, don't think this matters but worth mentioning
// FILE CONTAINING THE HEADER
.header__content {
height: 9.6rem;
padding: 3.6rem 2.4rem;
position: relative;
.nav {
display: flex;
align-items: stretch;
justify-content: space-between;
align-items: center;
margin-bottom: $margin-2;
.nav__list {
display: flex;
align-items: center;
list-style: none;
gap: 3rem;
}
.nav__items {
cursor: pointer;
}
.nav__items:hover {
color: $color-nav;
transition: all 0.2s;
}
.nav__right {
.nav__btn-register {
margin-top: 0;
border: 2px solid $color-grey-dark-2;
border-radius: 15px;
padding: 1em 2em;
/* Put transition on original "state" */
/* transition: background-color 0.3s; */
transition: all 0.3s;
}
.nav__btn-register:hover {
background-color: $bgC-1;
color: $color-btn;
}
}
.nav__left {
.nav__logo {
padding: $pd-1 $pd-1 0 0;
img {
height: 2em;
}
}
.nav__card {
position: absolute;
background-color: $bgC-card;
top: 2.4rem;
right: 1.2rem;
border-radius: 5px;
box-shadow: -1px 13px 42px -15px rgba(0, 0, 0, 0.47);
-webkit-box-shadow: -1px 13px 42px -15px rgba(0, 0, 0, 0.47);
-moz-box-shadow: -1px 13px 42px -15px rgba(0, 0, 0, 0.47);
}
}
.btn-mobile-nav {
cursor: pointer;
display: none;
}
.nav__menu-list {
position: relative;
// DROPDOWN ELEMENTS
.dropdown__list {
display: flex;
flex-direction: column;
gap: 1rem;
list-style: none;
font-size: $fs-00;
justify-items: flex-start;
.nav__menu-items {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 0.8rem;
}
}
}
.nav__company {
padding: 1.5rem;
width: 8rem;
}
.nav__features {
padding: 1.5rem 1.5rem;
}
.nav__company-items:hover,
.nav__features-items:hover {
transform: scale(1.05);
transition: all 0.1s;
}
}
}
// RESPONSIVE SASS FILE
$bp-Xlarge: 87.5em; // 1400px
$bp-large: 78.15em; // 1250px
$bp-mlarge: 65.625em; // 1050px
$bp-medium: 61.25em; // 980px
// Tablet
$bp-medium2: 55em; //880px
$bp-small: 47.75em; // 764px
$bp-small2: 37.5em; // 600px
$bp-smallest: 31.25em; // 500px
#media screen and (max-width: $bp-large) {
html {
font-size: 80%;
transition: all 0.3s ease-in-out;
}
.nav {
.nav__right,
.nav__left {
gap: 2.5rem;
}
}
.hero__left {
.hero__txt-header {
font-size: $fs-2a;
}
}
}
#media screen and (max-width: $bp-mlarge) {
html {
font-size: 72%;
}
.hero__left {
.hero__txt-header {
font-size: $fs-3;
}
}
.nav {
.nav__right,
.nav__left {
gap: 1.8rem;
}
}
.hero__left {
.btn__learn {
padding: 1.4rem 3rem;
}
}
}
#media screen and (max-width: $bp-medium) {
html {
font-size: 65%;
}
.grid {
gap: 5.5rem;
}
.hero__left {
.hero__txt-header {
font-size: $fs-3a;
}
.btn__learn {
padding: 1.4rem 3.5rem;
}
}
}
#media screen and (max-width: $bp-medium2) {
html {
font-size: 60%;
}
.nav {
// margin: $margin-1 $margin-2;
// justify-content: flex-end;
.nav__items,
.nav__right {
display: none;
}
.nav__logo {
display: block;
}
}
.btn-mobile-nav {
z-index: 9999;
display: block;
.btn__open {
display: block;
}
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- displays site properly based on user's device -->
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/src/images/favicon-32x32.png"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Epilogue:wght#500;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="src/sass/main.scss" />
<script defer src="/src/main.js"></script>
<title>Frontend Mentor | Intro section with dropdown navigation</title>
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
</head>
<body>
<header class="header__content">
<nav class="nav">
<div class="nav__left">
<ul class="nav__list nav__left-list">
<li class="nav__logo nav__items">
<img src="/src/images/logo.svg" alt="Logo icon" />
</li>
<li class="nav__items nav__menu-list">
Features
<img
src="/src/images/icon-arrow-down.svg"
alt="arrow down icon"
/>
<ul class="dropdown__list nav__card nav__features">
<li class="nav__menu-items">
<img
class="dropdown__img"
src="/src/images/icon-todo.svg"
alt=""
/>
Todo List
</li>
<li class="nav__menu-items">
<img
class="dropdown__img"
src="/src/images/icon-calendar.svg"
alt=""
/>
Calendar
</li>
<li class="nav__menu-items">
<img
class="dropdown__img"
src="/src/images/icon-reminders.svg"
alt=""
/>
Reminder
</li>
<li class="nav__menu-items">
<img
class="dropdown__img"
src="/src/images/icon-planning.svg"
alt=""
/>
Planning
</li>
</ul>
</li>
<li class="nav__items nav__menu-list">
Company
<img
src="/src/images/icon-arrow-down.svg"
alt="arrow down icon"
/>
<ul class="dropdown__list nav__card nav__company">
<li>History</li>
<li>Our Team</li>
<li>Blog</li>
</ul>
</li>
<li class="nav__items">Careers</li>
<li class="nav__items">About</li>
</ul>
</div>
<div class="nav__right">
<ul class="nav__list nav__right-list">
<li class="nav__items">Login</li>
<li class="nav__items nav__btn-register">Register</li>
</ul>
</div>
<div class="btn-mobile-nav">
<img
class="btn__open"
src="/src/images/icon-menu.svg"
alt="menu outline"
/>
<img
class="btn__close"
src="/src/images/icon-close-menu.svg"
alt="close menu outline"
/>
</div>
</nav>
</header>
Please help I don't know where I went wrong
Looks like the style is there but it gets overridden by the previous display: none; style.
In the last part of your scss
.btn-mobile-nav {
z-index: 9999;
display: block !important; // <--- add important
.btn__open {
display: block;
}
}
I can see the pages already hide when the user is in a small viewport
This question already has answers here:
Transitions on the CSS display property
(37 answers)
Closed 11 months ago.
I am newbie with html css and here is my problem.
I want to hide a block, then when I use an animation, it will show this block.
I refer a website and it tell me that I should use a CSS Pseudo Classes.
I tried it and at my 1st animation, I successfully to display the image.
Here is the code of the 1st animation
html code :
<div class="header__qr">
<img src="./assets/img/QRcode.png" alt="QR code" class="header__qr-img">
<div class="header__qr-apps">
<a href="" class="header__qr-link">
<img src="./assets/img/Googleplay.png" alt="Google play" class="header__qr-download-img">
</a>
<a href="" class="header__qr-link">
<img src="./assets/img/apple store.png" alt="App store" class="header__qr-download-img">
</a>
</div>
</div>
css code :
.header__qr {
width: 190px;
position: absolute;
left: 0;
top: 110%;
padding: 8px;
display: none;
animation: fadeIn ease-in 1s;
}
.header__qr::before {
position: absolute;
left: 0;
top: -16px;
width: 100%;
height: 20px;
content: "";
display: block;
}
and here is my 2nd animation code
<div class="header__notify">
<div class="header__img">
<img src="./assets/img/xemthongbao.png" alt="xemthongbao" class="header__notify-img">
</div>
<div class="header__notify-info">
<span class="header__notify-name">Đăng nhập để xem Thông báo</span>
</div>
<div class="register-info">
<div class="child register-register">Đăng ký</div>
<div class="child register-login">Đăng nhập</div>
</div>
</div>
css code is here
.header__notify {
background-color: white;
width: 400px;
position: absolute;
left: 0;
top: 110%;
padding: 20px;
display: none;
animation: fadeIn ease-in 1s;
}
.header__notify::before {
position: absolute;
left: 0;
top: -16px;
width: 100%;
height: 20px;
content: "";
display: block;
}
As you can see, the second code is very same as the first code, and when I delete the display:none, it display the image ? So I think that the CSS Pseudo Classes must be actived ? But it does not active as I wish.
Here is all of my code
https://github.com/anhquanjp/bai110headernotification
Could you please give me some ideas for this problem ? Thank you very much for your time.
Because that animation fadeIn set opacity 0 to 1 and header__notify has display none properity.
Add .header__navbar-item:hover .header__notify { display: block; } to your main Thong bao dropdown will work.
.header {
height: 120px;
background-image: linear-gradient(0, #fe6433, #f7482e);
}
.header__navbar {
display: flex;
justify-content: space-between;
}
.header__navbar-list {
list-style: none;
padding-left: 0;
margin-top: 14px;
}
.header__navbar-item {
margin: 0 8px;
position: relative;
min-height: 26px;
}
.header__navbar-item,
.header__navbar-item-link {
display: inline-block;
font-size: 1.3rem;
color: var(--white-color);
text-decoration: none;
font-weight: 3;
}
.header__navbar-item,
.header__navbar-item-link,
.header__navbar-icon-link {
display: inline-flex;
align-items: center;
}
.header__navbar-item:hover,
.header__navbar-icon-link:hover,
.header__navbar-item-link:hover {
color: rgba(255, 255, 255, 0.7);
cursor: pointer;
}
.header__navbar-item--bold {
font-weight: 500;
}
.header__navbar-item--separate::after {
content: "";
display: block;
position: absolute;
border-left: 1px solid #ffffff;
height: 16px;
right: -9px;
top: 50%;
transform: translateY(-50%);
}
.header__navbar-icon-link {
color: var(--white-color);
text-decoration: none;
}
.header__navbar-icon {
font-size: 1.8rem;
margin: 0 4px;
}
.header__navbar-title--no-pointer {
cursor: text;
color: var(--white-color);
}
.header__qr {
width: 190px;
position: absolute;
left: 0;
top: 110%;
padding: 8px;
display: none;
animation: fadeIn ease-in 1s;
}
.header__qr::before {
position: absolute;
left: 0;
top: -16px;
width: 100%;
height: 20px;
content: "";
display: block;
}
.header__navbar-item--has-qr:hover .header__qr {
display: block;
}
.header__qr-img {
}
.header__qr-apps {
display: flex;
justify-content: space-between;
}
.header__qr-download-img {
height: 18px;
}
.header__notify {
background-color: white;
width: 400px;
position: absolute;
left: 0;
top: 110%;
padding: 20px;
display: none;
animation: fadeIn ease-in 1s;
}
.header__notify::before {
position: absolute;
left: 0;
top: -16px;
width: 100%;
height: 20px;
content: "";
display: block;
}
.header__navbar-item:hover .header__notify {
display: block;
}
.header__img {
display: flex;
align-items: center;
justify-content: center;
height: 300px;
}
.header__notify-img {
width: 100px;
height: 100px;
display: block;
margin-left: auto;
margin-right: auto;
}
.header__notify-name {
color: black;
margin-top: 100px;
}
.register-info {
display: flex;
align-items: center;
justify-content: center;
}
.header__notify-info {
font-size: 14px;
font-weight: bold;
text-align: center;
}
.register-login,
.register-register {
font-size: 14px;
font-weight: bold;
background-color: rgb(248, 245, 245);
color: black;
float: left;
flex: 1;
text-align: center;
height: 30px;
width: 300px;
}
.register-login:hover,
.register-register:hover {
color: red;
background-color: rgb(238, 227, 227);
height: 30px;
}
:root {
--white-color: #fff;
--black-color: #000;
--text-color: #333;
}
* {
box-sizing: inherit;
}
html {
font-size: 100%;
line-height: 1.6rem;
font-family: "Roboto", sans-serif;
box-sizing: border-box;
}
.grid {
width: 1200px;
max-width: 100%;
margin: 0 auto;
}
.grid__full-width {
width: 100%;
}
.grid__row {
display: flex;
flex-wrap: wrap;
}
#keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#keyframes fadeInNotify {
from {
display: none;
}
to {
display: unset;
}
}
<!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>Document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
<link rel="stylesheet" href="./assets/css/base.css">
<link rel="stylesheet" href="./assets/css/main.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="assets/fonts/fontawesome-free-6.1.0-web/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght#0,100;0,300;1,100&display=swap" rel="stylesheet">
</head>
<body>
<!-- Block element modifier -->
<div class="app">
<header class="header">
<div class="grid">
<nav class="header__navbar">
<ul class="header__navbar-list">
<li class="header__navbar-item header__navbar-item--separate">Kênh Người Bán</li>
<li class="header__navbar-item header__navbar-item--separate">Trở thành Người bán Shopee</li>
<li class="header__navbar-item header__navbar-item--has-qr header__navbar-item--separate">Tải ứng dụng
<div class="header__qr">
<img src="./assets/img/QRcode.png" alt="QR code" class="header__qr-img">
<div class="header__qr-apps">
<a href="" class="header__qr-link">
<img src="./assets/img/Googleplay.png" alt="Google play" class="header__qr-download-img">
</a>
<a href="" class="header__qr-link">
<img src="./assets/img/apple store.png" alt="App store" class="header__qr-download-img">
</a>
</div>
</div>
</li>
<li class="header__navbar-item">
<span class="header__navbar-title--no-pointer">Kết nối</span>
<a href="" class="header__navbar-icon-link">
<i class="header__navbar-icon fa-brands fa-facebook-square"></i>
</a>
<a href="" class="header__navbar-icon-link">
<i class="header__navbar-icon fa-brands fa-instagram"></i>
</a>
</li>
</ul>
<ul class="header__navbar-list">
<li class="header__navbar-item">
<a href="" class="header__navbar-item-link">
<i class="header__navbar-icon fa-solid fa-bell"></i> Thong bao
<div class="header__notify">
<div class="header__img">
<img src="./assets/img/xemthongbao.png" alt="xemthongbao" class="header__notify-img">
</div>
<div class="header__notify-info">
<span class="header__notify-name">Đăng nhập để xem Thông báo</span>
</div>
<div class="register-info">
<div class="child register-register">Đăng ký</div>
<div class="child register-login">Đăng nhập</div>
</div>
</div>
</a>
</li>
<li class="header__navbar-item">
<a href="" class="header__navbar-item-link">
<i class="header__navbar-icon fa-solid fa-circle-question"></i> Ho tro</a>
</li>
<li class="header__navbar-item header__navbar-item--bold header__navbar-item--separate">Tro giup</li>
<li class="header__navbar-item header__navbar-item--bold">Dang nhap</li>
</ul>
</nav>
</div>
</header>
<div class="container">
</div>
<footer class="footer">
</footer>
</div>
</body>
</html>
Everyone, I face a problem, please first look image, then check my code, i am shohel in image. I want to scroll down with icon add or move in my image right side and same social media icon in my image left side as like Ansell Klee image. and when i right bottom increase but not any happened in my browser, not working, why this happened? I don't understand Advanced love and thanks.
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#400;500;600&display=swap');
/*=============== VARIABLES CSS ===============*/
:root {
--header-height: 3.5rem;
/*========== Colors ==========*/
--first-hue: 250;
--sat:66%;
--lig:75%;
--second-hue:219;
--first-color: hsl(var(--first-hue),var(--sat),var(--lig));
--first-color-alt : hsl(var(--first-hue),var(--sat),71%);
--titel-color: hsl(var(--second-hue),15%,95%);
--text-color: hsl(var(--second-hue),8%,75%);
--text-color-light: hsl(var(--second-hue),4%,55%);
--body-color:hsl(var(--second-hue),48%,8%);
--container-color:hsl(var(--second-hue), 32%,12%);
/*========== Font and typography ==========*/
--body-font: 'Poppins', sans-serif ;
--biggest-font-size: 2rem;
--h1-font-size: 1.5rem;
--h2-font-size: 1.25rem;
--h3-font-size: 1rem;
--normal-font-size: .938rem;
--small-font-size: .813rem;
--smaller-font-size: .75rem;
/*========== Font weight ==========*/
--font-medium: 500;
--font-bold: 700;
/*========== Margenes Bottom ==========*/
--mb-0-5: .5rem;
--mb-0-75: .75rem;
--mb-1: 1rem;
--mb-1-5: 1.5rem;
--mb-2: 2rem;
--mb-2-5: 2.5rem;
--mb-3: 3rem;
/*========== z index ==========*/
--z-tooltip: 10;
--z-fixed: 100;
}
#media screen and (min-width: 968px) {
:root {
--biggest-font-size: 2.5rem;
--h1-font-size: 2.25rem;
--h2-font-size: 1.5rem;
--h3-font-size: 1.25rem;
--normal-font-size: 1rem;
--small-font-size: .875rem;
--smaller-font-size: .813rem;
}
}
/* Base */
*{
box-sizing: border-box;
padding: 0;
margin: 0;
}
html{
scroll-behavior: smooth;
}
body,button,input,textarea{
font-family: var(--body-font);
font-size: var(--normal-font-size);
}
body{
background-color: var(--body-color);
color: var(--text-color);
}
h1,h2,h3{
color: var(--titel-color);
font-weight: var(--font-medium);
}
ul{
list-style: none;
}
a{
text-decoration: none;
}
button{
cursor: pointer;
border: none;
outline: none;
}
img{
max-width: 100%;
height: auto;
}
.container{
max-width: 968px;
margin-left: 1rem;
margin-right: 1rem;
}
.grid{
display: grid;
gap: 1.25rem;
}
.main{
overflow: hidden;
}
.section{
padding: 4.5rem 0 1rem;
}
.section__title,
.section__subtitle{
text-align: center;
}
.section__title{
font-size: var(--h2-font-size);
color: var(--first-color);
margin-bottom: 2rem;
}
.section__subtitle{
display: block;
font-size:var(--smaller-font-size) ;
color: var(--text-color-light);
}
/* header and nav */
.header{
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color:var(--body-color);
z-index: var(--z-fixed);
}
.nav{
height: var(--header-height);
display: flex;
justify-content: space-between;
align-items: center;
}
.nav__logo{
color: var(--first-color);
font-weight: var(--font-medium);
transition: .4s;
}
.nav__logo:hover{
color: var(--first-color-alt);
}
.nav__menu{
position: fixed;
bottom: 1rem;
background: hsla(var(--second-hue),32%,16%,.8);
width: 90%;
border-radius: 4rem;
padding: 1rem 2.25rem;
backdrop-filter: blur(10px);
}
.nav__list{
display:flex ;
justify-content: space-between;
align-items: center;
}
.nav__link{
color: var(--text-color);
font-size: 1.25rem;
padding: .4rem;
display: flex;
border-radius: 5rem;
}
/* acrive-link */
.active-link{
background: linear-gradient(180deg,hsla(var(--first-hue),var(--sat),var(--lig),1), hsla(var(--first-hue),var(--sat),var(--lig),.2)
);
box-shadow: 0 0 16px hsla(var(--first-hue),var(--sat),var(--lig),.4);
}
/* home */
.home__container{
position: relative;
row-gap: 4.5rem;
padding-top: 2rem;
}
.home__data{
text-align: center;
}
.home__greeting,
.home__education{
font-size: var(--small-font-size);
font-weight: var(--font-medium);
}
.home__greeting{
display: block;
color: var(--titel-color);
margin-bottom: .25rem;
}
.home__education{
color: var(--text-color);
margin-bottom: 2.5rem;
}
.home__name{
font-size: var(--biggest-font-size);
}
.home__img{
width:160px;
}
.home__handel{
justify-self: center;
width: 190px;
height: 244px;
background: linear-gradient(180deg,
hsla(Var(--first-hue), var(--sat), var(--lig),1),
hsla(Var(--first-hue), var(--sat), var(--lig), .2)
);
border-radius: 10rem 10rem 1rem 1rem;
display: flex;
align-items: flex-end;
justify-content: center;
overflow: hidden;
}
.home__buttons{
display: flex;
justify-content: center;
align-items: center;
gap: 1.5rem;
}
.home__social,
.home-scroll
{
position:absolute ;
}
.home__social{
bottom: 9rem;
left: 0;
display: grid;
row-gap: .5rem;
}
.home__social-link{
width: max-content ;
background-color: var(--container-color);
color: var(--text-color);
padding: .25rem;
border-radius: .25rem;
display: flex;
font-size: 1rem;
transition: .4s;
}
.home__social-link:hover{
background-color: var(-first-color);
color:#fff;
}
.home__social::after{
content: '';
width: 32px;
height: 2px;
background-color: var(--first-color);
transform: rotate(90deg) translate(16px,3px);
}
.home__scroll{
color: var(--first-color);
right: -1.5rem;
bottom: 4rem;
display: grid;
row-gap: 2.25rem;
justify-items: center;
}
.home__scroll-icon{
font-size: 1.25rem;
}
.home__scroll-name{
font-size: var(--smaller-font-size);
transform: rotate(-90deg);
}
.button{
display: inline-block;
background-color: var(--first-color);
color: var(--body-color);
padding: .75rem 1rem;
border-radius: .5rem;
font-weight: var(--font-medium);
transition: .4s;
}
.button:hover{
background-color:var(--first-color-alt);
color: var(--body-color);
}
.button-ghost{
background-color: transparent;
border: 2px solid var(--first-color);
color: var(--first-color);
}
<!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>Responsive shohel Portfolio Website </title>
<link rel="stylesheet" href="style.css">
<link href='https://unpkg.com/boxicons#2.1.1/css/boxicons.min.css' rel='stylesheet'>
<script src="./script.js" defer></script>
</head>
<body>
<header class="header" id="header">
<nav class="nav container">
Shohel
<div class="nav__menu">
<ul class="nav__list">
<li class="nav__item">
<a href="#home" class="nav__link active-link">
<i class='bx bx-home-alt'></i>
</a>
</li>
<li class="nav__item">
<a href="#about" class="nav__link">
<i class='bx bx-user' ></i>
</a>
</li>
<li class="nav__item">
<a href="#skills" class="nav__link">
<i class='bx bx-book' ></i>
</a>
</li>
<li class="nav__item">
<a href="#work" class="nav__link">
<i class='bx bx-briefcase-alt-2' ></i>
</a>
</li>
<li class="nav__item">
<a href="#contact" class="nav__link">
<i class='bx bx-message-square-detail' ></i>
</a>
</li>
</ul>
</div>
<!-- theme change button -->
<i class='bx bx-moon change-theme' id="theme-button" ></i>
</nav>
</header>
<!-- Main -->
<main class="main">
<!--Home -->
<section class="home section" id="home">
<div class="home__container container grid">
<div class="home__data">
<span class="home__greeting">Hellow, I'm</span>
<h1 class="home__name">Shohel</h1>
<h3 class="home__education">Frontend Developer</h3>
<div class="home__buttons">
Download CV
About Me
</div>
</div>
<div class="home__handel">
<img src="./img/IMG_20220127_145041_1-02-removebg-preview.png" alt="" class="home__img">
</div>
<div class="home__social">
<a href="" class="home__social-link">
<i class='bx bxl-linkedin-square' ></i>
</a>
<a href="" class="home__social-link">
<i class='bx bxl-github' ></i>
</a>
<a href="" class="home__social-link">
<i class='bx bxl-dribbble' ></i>
</a>
</div>
<a href="" class="home__scroll">
<i class='bx bx-mouse home__scroll-icon' ></i>
<span class="home__scroll-name">Scroll Down</span>
</a>
</div>
</section>
</main>
</body>
</html>
add a property as position:absolute to the same class
.home__scroll{color: var(--first-color);
right: -1.5rem;
bottom: 11rem;
display: grid;
row-gap: 2.25rem;
justify-items: center;
position: absolute;}
You need to add property position: absolute; OR position: fixed; according to your requirement before adding top:; OR right:; OR bottom:; OR left:;
This is because these properties only work with positioned elements other than position: static;
So I have this navigation bar that is unresponsive. So far what I have learned is to use margin percentage values and flex attributes. However, I have a horrible time trying to apply these fixes to the navbar that I have buried in bad styling.
There isn't one exact thing with this navbar, but I can say that the right-hand links will not shrink with the screen or even stay inside the viewport. Note that at 767px width the collapse menu appears and that becomes a whole other set of issues.
And this might be a bit much, but if you could explain to me the errors that way I know what not to do. Thanks!
// When the user scrolls the page, execute myFunction
window.onscroll = function() {
myFunction();
myFunction2();
};
// Get the navbar
var navbar = document.getElementById("navbar");
// Get the offset position of the navbar
var sticky = navbar.offsetTop;
// Add the sticky class to the navbar when you reach its scroll position. Remove
"sticky"
when you leave the scroll position
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky");
} else {
navbar.classList.remove("sticky");
}
}
// Get the logo
var logo = document.getElementById("logo");
// Get the offset position of the logo
var logoSpin = logo.offsetTop;
// Add the logo-spin class to the navbar when you reach its scroll position. Remove
"logo-spin"
when you leave the scroll position
function myFunction2() {
if (window.pageYOffset >= logoSpin) {
logo.classList.add("logo-spin");
} else {
logo.classList.remove("logo-spin");
}
}
// All links will have a target:__blank for external page linking
// Read more: https://html.com/attributes/a-target/#ixzz6GMsDfQEr
// jQuery(document.links)
// .filter(function() {
// return this.hostname != window.location.hostname;
// })
// .attr("target", "_blank");
//OR Read more: https://html.com/attributes/a-target/#ixzz6GN6pd1Qt
function externalLinks() {
for (var c = document.getElementsByTagName("a"), a = 0; a < c.length; a++) {
var b = c[a];
b.getAttribute("href") &&
b.hostname !== location.hostname &&
(b.target = "_blank");
}
}
externalLinks();
html,
body {
background-color: #E3E3E3;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
/* font-size: 15px; */
}
/* h1 { font-size: 2.4rem;}
h2 { font-size: 2rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.2rem; }
h5 { font-size: 1rem; }
#media screen and (max-width:767px){
h1 { font-size: 3rem;}
h2 { font-size: 2.5rem; }
h3 { font-size: 2rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1rem; }
} */
/* HOME */
.section1 {
background: url("../images/laptop-table1920-gray.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-size: cover;
background-attachment: scroll;
width: 100%;
height: 100%;
}
.section1 .container {
background-color: rgb(0, 0, 0, 0.65);
min-height: -webkit-fill-available;
min-width: -webkit-fill-available;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
.home-btn {
background-color: transparent;
font-weight: 500;
border-color: #8e0000;
border-radius: 3px;
color: #8e0000;
margin-top: 35px;
font-size: 1.12em;
transform: translate(-50%, -50%);
position: absolute;
text-shadow: .1px .8px 1px black;
-webkit-filter: drop-shadow(0px 3px 10px rgba(0, 0, 0, .8));
filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, .8));
}
/* hover styling required !important */
.home-btn:hover {
color: #8e0000 !important;
border-color: #8e0000;
font-size: 1.4em;
border-width: 3px;
font-weight: 600;
text-shadow: .1px 2px 1px black;
-webkit-filter: drop-shadow(0px 3px 10px rgba(0, 0, 0, .8));
filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, .8));
}
.intro {
color: white;
font-size: 2.74em;
text-shadow: .1px .8px 1px black;
}
.highlight {
color: #8e0000;
text-shadow: .1px .8px 1px black;
}
/* NAVIGATION */
#navbar,
.navbar {
display: flex;
min-width: 100%;
min-height: 80px;
}
#media screen and (max-width: 767px) {
#navbar {
min-height: 100px !important;
}
}
#navbar .container {
display: inline-flex;
}
.logo {
display: inline-flex;
flex-direction: row;
-webkit-filter: drop-shadow(0px 3px 10px rgba(0, 0, 0, .8));
filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, .8));
}
.navbar-brand {
margin: 0%;
padding: 0% !important;
}
#navbar .nav-link {
float: right;
}
#media screen and (max-width: 767px) {
#navbar .nav-link {
padding-right: 50%;
}
}
#navbar .nav-link:focus {
color: #8e0000;
text-size-adjust: 1.4em;
}
.logo-wrapper {
color: white;
font-family: 'Raleway', sans-serif;
text-shadow: .1px 2px 1px black;
display: inline-flex;
margin-left: 15%;
}
#navbar .logo,
.brand {
margin: 7%;
color: #f2f2f2;
}
.collapse {
margin-left: 20%;
font-size: .9rem;
}
#navbar a {
color: #f2f2f2;
text-align: center;
/* padding: 0px 20px; */
text-decoration: none;
vertical-align: top !important;
/* font-size: 20%; */
font-family: 'Raleway', sans-serif;
text-shadow: .1px 1px 1px black;
/* margin-right: 40px; */
}
.logo-spin {
-webkit-animation: spin 1s;
animation: spin 3s;
animation-iteration-count: 1;
}
.navbar-brand:hover {
-webkit-animation: spin 1s;
animation: spin 3s;
animation-iteration-count: 1;
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotateY(360deg);
}
100% {
-webkit-transform: rotateY(-360deg);
}
}
#keyframes spin {
from {
-moz-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-moz-transform: rotateY(-360deg);
-ms-transform: rotateY(-360deg);
transform: rotateY(-360deg);
}
}
.navbar {
background-color: #333;
height: 65px;
border-bottom: 6px solid #212529;
border-top: 6px solid #212529;
}
#navbar {
z-index: 9999;
}
.navbar-text {
vertical-align: middle;
margin-right: 40%;
height: inherit;
overflow: hidden;
}
#media only screen and (max-width: 860px) {
.navbar-text {
display: inline-block;
align-items: center;
margin-left: 30px;
}
}
.sticky {
position: fixed;
top: 0;
width: 100%;
margin-bottom: 60px;
}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Information meta tags -->
<meta name="description" content="A portfolio page for Bernard Major">
<meta http-equiv="author" content="King Major">
<!--LOCAL-->
<!-- <link rel="stylesheet" type="text/css" href="assets/css/reset.css"> -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<!-- Bootstrap CSS HOSTED-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!--LOCAL-->
<link rel="stylesheet" type="text/css" href="assets/css/animate.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/icon.css">
<!-- FAVICON -->
<link rel="shortcut icon" href="favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<!-- FONTAWESOME -->
<script src="https://kit.fontawesome.com/3376f28ddc.js" crossorigin="anonymous">
</script>
<title>King Major</title>
</head>
<body>
<!-- HOME -->
<section id="home" class="section1">
<div class='container'>
<div class="row justify-content-center">
<div class="col-md-12 col-sm-12">
<p class='intro'>
Hello, my name is <span class="highlight animated fadeIn" style="animation-delay: 1s; animation-duration: 1.8s">Ben.</span>
<br>
<div class="intro animated fadeInLeft" style="animation-delay: 3s;
animation-duration: 2s">And I'm a full-stack web developer.</div>
<a href="#myanchor"><button type="button" class="home-btn btn btn-primary-
outline btn-xs animated fadeIn"
style="animation-delay: 5s; animation-duration: 2s">VIEW MY
WORK</button></a>
</p>
</div>
</div>
</div>
</section>
<!-- NAVIGATION -->
<div id="navbar">
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<!-- <div class="container"> -->
<div class="logo-wrapper nav-item">
<div class="logo" id="logo">
<a class="navbar-brand" href="#home"><img src="favicon.ico" alt="King's
Brand Logo"></a>
</div>
<span class="brand" id="brand" style="animation-delay: 0s; animation-duration:
3s">Been There</span>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data- target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle
navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item focus">
<a class="nav-link" href="#myanchor">ABOUT
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#myanchor2">SKILLS
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#myanchor3">PROJECTS
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#myanchor4">TESTIMONIALS
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://kingdomb.github.io/mailer/">CONTACT
<span class="sr-only">(current)</span>
</a>
</li>
</ul>
</div>
<!-- </div> -->
</nav>
</div>
First and foremost, the navbar was hidden when I run the code. You can change it so it will appear at the top by setting the order like so:
<div id="navbar">...</div>
<section id="home" class="section1">...</section>
For the issue of responsiveness on the navbar, I notice you used bootstrap for constructing the navbar. Bootstrap has a set of breakpoints set in the framework, these are:
// Extra small devices (portrait phones, less than 576px)
// No media query for xs since this is the default in Bootstrap
// Small devices (landscape phones, 576px and up)
#media (min-width: 576px) { ... }
// Medium devices (tablets, 768px and up)
#media (min-width: 768px) { ... }
// Large devices (desktops, 992px and up)
#media (min-width: 992px) { ... }
// Extra large devices (large desktops, 1200px and up)
#media (min-width: 1200px) { ... }
For the case of the navbar, it is by default responsive already, you just need to follow the markup structure in their site. You can read more here for the navbar breakpoints:
https://medium.com/wdstack/examples-bootstrap-4-navbar-b3c9dc0edc1a
Also, by default, bootstrap's original .navbar element has display: flex on it, so any thing that you put inside it will flow along with its adjacent elements. You can read more about flex attribute here:
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
How to create a left navbar with bootstrap ?
I did it
<nav class="btn-group-vertical float-left navbar">
<button routerLink="product/home" routerLinkActive="is-active" class="btn btn-outline-dark">Home</button>
<button routerLink="product/favorite" routerLinkActive="is-active" class="btn btn-outline-dark">Favorite</button>
</nav>
But the problem that i see it as unexpected
I want that all hoe work be with good position
but use bootstrap 4 well
Thank for help :-)
As I understood,you're trying to create side navbar and want to show component on the right side.In this case when you call a component by routerLink,a specific css should be applied to each called component in order to see them on the right.
<style>
router-outlet + * {
float:right;
position:absolute;
}
</style>
This css code will be applied for each component brought by router-outlet.If you want you can add some margin.
Here you can see what I've done for you :
https://stackblitz.com/edit/angular-router-basic-example-pgr1tv?file=index.html
Here it is a nice, modern and responsive approach that I used in one of my projects. I hope it helps.
Note: The javascript part would be replaced by a shared service in your angular application's core module where you should use BehaviourSubject to communicate the state of the sidenav from another component.
Quick example:
export class SidenavService {
private sidenavState$ = new BehaviorSubject<boolean>(false);
...
const sidenav = document.querySelector('#sidenav');
const toggleSidenav = state => {
sidenav.className = state ?
sidenav.className.replace('closed', 'opened') :
sidenav.className.replace('opened', 'closed');
}
.grid-container {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 60px 1fr 60px;
grid-template-areas: 'header''main''footer';
height: 100vh;
}
#media only screen and (min-width: 768px) {
.grid-container {
grid-template-columns: 260px 1fr;
grid-template-areas: "sidenav header""sidenav main""sidenav footer";
}
}
.sidenav {
grid-area: sidenav;
display: flex;
flex-direction: column;
height: 100%;
width: 260px;
padding: 0 .8rem;
position: fixed;
overflow-y: auto;
z-index: 4;
transform: translateX(-300px);
box-shadow: 0 1rem 2rem rgba(0, 0, 0, .5);
transition: all .1s linear;
background-color: #fff;
}
.sidenav.opened {
transform: translateX(0);
}
.sidenav__open-icon:hover {
background-color: #ececec;
}
.sidenav__close-icon {
position: absolute;
visibility: visible;
top: 5px;
right: 5px;
cursor: pointer;
font-size: 20px;
width: 20px;
height: 20px;
color: #e0e0e0;
display: grid;
place-items: center;
border: solid 1px transparent;
border-radius: 50%;
background-color: transparent;
}
#media only screen and (min-width: 768px) {
.sidenav {
transform: translateX(0);
}
.sidenav__close-icon {
visibility: hidden;
}
}
ul.sidenav__list {
padding: 0;
margin-top: 1rem;
list-style-type: none;
max-width: 340px;
overflow-y: auto;
}
li.sidenav__list-item {
margin-bottom: 4px;
background-color: #ddd;
border: solid 1px transparent;
border-radius: 6px;
border-bottom: solid 4px #d2d2d2;
}
li.sidenav__list-item>a {
width: 100%;
padding: .7rem 1rem;
display: block;
position: relative;
color: #333;
text-decoration: none;
}
li.sidenav__list-item>a:hover,
li.sidenav__sublist-item>a:hover {
background-color: #d2d2d2;
cursor: pointer;
}
.sidenav__icon {
width: 40px;
padding: 0 2px;
display: inline-block;
margin-right: .4rem;
}
li.sidenav__list-item>a .caret {
position: absolute;
right: 16px;
top: auto;
}
li.sidenav__list-item>a .caret>i {
font-size: 12px;
}
ul.sidenav__sublist {
padding: 0;
list-style-type: none;
}
li.sidenav__sublist-item:first-child {
margin: .5rem 0 0;
}
li.sidenav__sublist-item>a {
width: 100%;
padding: .5rem 1rem;
font-size: 80%;
display: block;
position: relative;
color: #333;
border: solid 1px transparent;
border-radius: 4px;
}
[role="nav-menu"],
[role="nav-dropdown-item"] {
cursor: pointer !important;
}
[role="nav-dropdown"] {
cursor: default !important;
}
.header {
grid-area: header;
background-color: #ddd;
}
main {
grid-area: main;
}
footer {
grid-area: footer;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="grid-container">
<div id="sidenav" class="sidenav closed">
<ul class="sidenav__list">
<li class="sidenav__list-item">
<!-- Menú con navegación -->
<a role="nav-menu">
<span class="sidenav__icon">
<i class="{{m.iconoMenu}}"></i>
</span>
<span class="sidenav__title">Home</span>
</a>
</li>
<!-- Menú sin navegación -->
<li class="sidenav__list-item">
<a class="accordion-toggle collapsed toggle-switch" data-toggle="collapse" href="#submenu-1" role="nav-dropdown">
<span class="sidenav__icon">
<i class="fas fa-home"></i>
</span>
<span class="sidenav__title">
Configuration
</span>
<b class="caret">
<i class="fas fa-caret-down"></i>
</b>
</a>
<ul id="submenu-1" class="sidenav__sublist panel-collapse collapse panel-switch" role="menu">
<li class="sidenav__sublist-item" role="nav-dropdown-item">
<a href="#">
<span class="sidenav__icon"><i class="fas fa-cog"></i></span>
<span class="sidenav__title">Option 1</span>
</a>
</li>
<li class="sidenav__sublist-item" role="nav-dropdown-item">
<a href="#">
<span class="sidenav__icon"><i class="fas fa-cog"></i></span>
<span class="sidenav__title">Option 2</span>
</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="header">
<div class="container-fluid">
header
</div>
</div>
<main>
<div class="container-fluid">
body
</div>
</main>
<footer>
<div class="container-fluid">
footer
</div>
</footer>
</div>
<div style="position: absolute; right: 40px; top: 80px">
<button onclick="toggleSidenav(true)">open</button>
<button onclick="toggleSidenav(false)">close</button>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>