I am trying to create a vertical timeline having this codepen as reference but unfortunately it's not working for me.
My code is here in this sandbox
App.js
import styles from "./styles.module.css";
export default function App() {
return (
<div className="App">
<div className={styles.carouselContentWrapper}>
<div className={styles.year}>
<span>2021</span>
</div>
<ul className={styles.textWrapper}>
<li className={styles.text1}>Text1</li>
<li className={styles.text2}>Text2</li>
</ul>
</div>
</div>
);
}
Styles.module.css
.textWrapper ul li {
list-style-type: none;
position: relative;
width: 6px;
margin: 0 auto;
padding-top: 50px;
background: #fff;
}
.textWrapper ul li::after {
content: "";
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: 30px;
height: 30px;
border-radius: 50%;
background: inherit;
z-index: 1;
}
Any ideas on what is causing this would be much appreciated.
Note: Just to mention that I am using css modules in my original project so would like it to work by using css modules.
You can put text in div so you can position it:
.textWrapper ul li {
list-style-type: none;
position: relative;
width: 6px;
margin: 0 auto;
padding-top: 50px;
background: #fff;
}
.textWrapper ul li::after {
content: "";
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: 30px;
height: 30px;
border-radius: 50%;
background: inherit;
z-index: -1;
}
.textWrapper ul li div {
position: absolute;
left: 20px;
top: 25px;
color: white;
}
body {
background-color: blueviolet
}
<div class="App">
<div class={styles.carouselContentWrapper}>
<div class={styles.year}>
<span>2021</span>
</div>
<div class=textWrapper>
<ul>
<li class={styles.text}>
<div>Text1</div>
</li>
<li class={styles.text}>
<div>Text2</div>
</li>
</ul>
</div>
</div>
</div>
it works as reference codepan. give background color to your ul or change for li.
Related
i am trying to create a CSS Animation for a vertical line going upwards - the line should be within a specific div
I have used gsap - i have used as well ypercent field, however the line starts from below the FirstScene div while i need it to be contained within the FirstScene div
gsap.fromTo(".vertical-line",{ yPercent:10 }, {yPercent:0,duration: 5});
* {
margin: 0;
padding: 0
}
.topnav {
position: sticky;
top: 0;
font-size: x-large;
background-color: black;
position: -webkit-sticky;
overflow: hidden;
z-index: 1;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
}
li {
float: right;
padding: 8px;
color: white;
display: inline;
}
linkStyle {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li i {
color: white;
text-decoration: none;
}
li a {
color: white;
text-decoration: none;
}
#li-left {
float: left;
}
body {
margin: 0px;
height: 100%;
}
.FirstScene {
background-color: black;
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
.line {
left: 50%;
top: 50%;
width=10px;
height: 50%;
position: absolute;
}
.vertical-line {
border-left: 6px solid blue;
height: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js"></script>
<div class="topnav">
<ul>
<li id="li-left">
<Link to="/" class="linkStyle"> MINA IBRAHIM
</Link>
</li>
<li>
<a href="https://github.com/ibrahimmina">
<i class="fa-brands fa-github"></i>
</a>
</li>
<li>
<a href="https://www.linkedin.com/in/minasamyibrahim/">
<i class="fa-brands fa-linkedin"></i>
</a>
</li>
<li>
.email()
</li>
<li>
<Link to="/about" class="linkStyle"> .about()
</Link>
</li>
</ul>
</div>
<body>
<section class="FirstScene">
<div class="line">
<div class="vertical-line">
</div>
</div>
</section>
</body>
Please use the bellow css for the Vertical Line Going Upwards animations
.FirstScene{
background-color: black;
position:absolute;
top:0px;
right:0px;
bottom:0px;
left:0px;
}
.vertical-line{
border-left: 6px solid blue;
animation-name: line;
animation-duration: 5s;
animation-iteration-count: 1;
left: 0;
height: 50%;
width: 10px;
position: absolute;
bottom: 0;
right: 0;
margin: 0 auto;
}
#keyframes line{
0%{
height: 0px;
}
100%{
height: 50%;
}
}
To make sure the media query was actually working and the problem not being me setting the wrong max-width, I set the nav bar to change color and height when the max width was reached. My main goal was for the search bar to move further to the left but this doesn't work (the change in background color was for visual purposes). Why is this so? I'm trying to reposition the search bar as it glitches once the screen gets smaller.
nav ul {
display: inline-flex;
list-style: none;
transform: translate(16%);
}
nav ul li {
margin-right: 50px;
}
.search {
border-radius: 40px;
background-color: rgb(255, 255, 255);
display: inline-flex;
height: 35px;
transform: translate(180px, -1px);
}
.search input {
position: relative;
left: 10px;
top: 0px;
outline: none;
width: 0px;
border: none;
background: transparent;
transition: 0.5s;
}
search:hover input {
width: 150px;
}
.btn {
height: 35px;
width: 35px;
border-radius: 35px;
background-color: lightseagreen;
}
.btn i {
position: Relative;
top: 9px;
left: 9px;
}
#media screen and (max-width: 1380px) {
nav {
background-color: greenyellow;
height: 40px;
}
.search {
background-color: indigo;
}
}
<nav>
<ul>
<li><a href=#>word1</a></li>
<li><a href=#>word2</a></li>
<li><a href=#>word3</a></li>
</ul>
<div class="search">
<input type="text" placeholder="search">
<div class=btn>
<i class="fas fa-search"></i>
</div>
</div>
</nav>
Your media query is working as expected: The background-colors are applied and the height is set. The background-color for .search wasn't so good visible because the search input has a width: 0px - therefor i tested with 50px. The change of the height wasn't visible because everything was white - therefor i tested with:
nav {
background-color: #ccc;
}
Now you can see that on big screens the nav has no height (= auto) and on small screens 40px (use the browsers dev tools).
Working example:
nav {
background-color: #ccc;
}
nav ul {
display: inline-flex;
list-style: none;
transform: translate(16%);
}
nav ul li {
margin-right: 50px;
}
.search {
border-radius: 40px;
background-color: lightcoral;
display: inline-flex;
height: 35px;
transform: translate(180px, -1px);
}
.search input {
position: relative;
left: 10px;
top: 0px;
outline: none;
width: 0px;
border: none;
background: transparent;
transition: 0.5s;
}
.search:hover input {
width: 150px;
}
.btn {
height: 35px;
width: 35px;
border-radius: 35px;
background-color: lightseagreen;
}
.btn i {
position: Relative;
top: 9px;
left: 9px;
}
#media screen and (max-width: 1380px) {
nav {
background-color: greenyellow;
height: 40px;
}
.search {
background-color: indigo;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
<nav>
<ul>
<li><a href=#>word1</a></li>
<li><a href=#>word2</a></li>
<li><a href=#>word3</a></li>
</ul>
<div class="search">
<input type="text" placeholder="search">
<div class=btn>
<i class="fas fa-search"></i>
</div>
</div>
</nav>
Alternative example:
with display: flex for the whole nav container and deactivated transform for the ul in the media query
nav {
display: flex;
justify-content: space-between;
background-color: #ccc;
}
nav ul {
display: inline-flex;
list-style: none;
transform: translate(16%);
}
nav ul li {
margin-right: 50px;
}
.search {
border-radius: 40px;
background-color: lightcoral;
display: inline-flex;
height: 35px;
}
.search input {
position: relative;
left: 10px;
top: 0px;
outline: none;
width: 0px;
border: none;
background: transparent;
transition: 0.5s;
}
.search:hover input {
width: 150px;
}
.btn {
height: 35px;
width: 35px;
border-radius: 35px;
background-color: lightseagreen;
}
.btn i {
position: Relative;
top: 9px;
left: 9px;
}
#media screen and (max-width: 1380px) {
nav {
background-color: greenyellow;
height: 40px;
}
nav ul {
transform: none;
}
.search {
background-color: indigo;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
<nav>
<ul>
<li><a href=#>word1</a></li>
<li><a href=#>word2</a></li>
<li><a href=#>word3</a></li>
</ul>
<div class="search">
<input type="text" placeholder="search">
<div class=btn>
<i class="fas fa-search"></i>
</div>
</div>
</nav>
If it is not working for all the div's, check if you forgot to put <meta content="width=device-width, initial-scale=1" name="viewport" /> inside your <head> </head> tags where you have your HTML code. This should do the trick.
I have come across a very strange bug that only applies to ie11 on windows 7:
When applying pointer-events: none to a parent element, pointer-events:auto will not work on an element with that is display:inline-block
It may happen on windows 8 too but it seems to have fixed itself on Windows 10.
Below is an example snippet of what I mean, you can see the screen will turn light blue when ever it is hovered. I have removed the pointer events for everything and then turned it back on for the green box and the opaque white breadcrumb list.
You can see the green box turns has it's own pointer events (turning the background back to dark blue) where as the breadcrumb is totally ignored
html,
body {
position: relative;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#total {
position: absolute;
z-index: 1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: blue;
display: block;
}
#total:hover {
background: lightblue
}
.no-pointer {
position: absolute;
left: 20px;
top: 150px;
width: 200px;
height: 200px;
border: 1px solid red;
z-index: 2;
pointer-events: none;
}
.pointer {
position: relative;
width: 100px;
height: 100px;
pointer-events: auto;
background: green;
display: block;
}
#breadcrumb {
position: absolute;
top: 20px;
left: 0;
right: 0;
max-width: 500px;
margin: auto;
width: 100%;
pointer-events: none;
z-index: 2;
}
.breadcrumb-list {
list-style: none;
background-color: #ffffff;
background-color: rgba(255, 255, 255, 0.5);
display: inline-block;
padding: 1em 50px;
pointer-events: auto;
}
.list-item {
display: inline-block;
}
<a id="total" href="#"></a>
<div class="no-pointer">
</div>
<div id="breadcrumb">
<ol class="breadcrumb-list">
<li class="list-item home-crumb">
<a class="crumb" href="#1">
<span>Home</span>
</a>
</li>
<li class="list-item">
<a class="crumb" href="#2">
<span>Test</span>
</a>
</li>
<li class="list-item">
<a class="crumb" href="#3">
<span>Test 2</span>
</a>
</li>
</ol>
</div>
Is there anyway to get this inline-block to work with ie11 on windows 7 (and maybe windows 8)?
ps I have used browser stack to test this and it worked properly on the setup I have described, so not sure if this is just localised to one laptop as I don't have any other windows 7 machines to test it on
Here is a fiddle I have messed around with
If you use the above fiddle and turn the inline-block element to a block element, you can see the pointer events work again
Luckily I have not used inline-block for centering the content but just so the element is able to be padded around the content.
This has meant that I can go back old school (in the days before inline-block) and float the element and make it block:
html,
body {
position: relative;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#total {
position: absolute;
z-index: 1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: blue;
display: block;
}
#total:hover {
background: lightblue
}
.no-pointer {
position: absolute;
left: 20px;
top: 150px;
width: 200px;
height: 200px;
border: 1px solid red;
z-index: 2;
pointer-events: none;
}
.pointer {
position: relative;
width: 100px;
height: 100px;
pointer-events: auto;
background: green;
display: block;
}
#breadcrumb {
position: absolute;
top: 20px;
left: 0;
right: 0;
max-width: 500px;
margin: auto;
width: 100%;
pointer-events: none;
z-index: 2;
}
#breadcrumb:after {
content: '';
display: block;
height: 0;
overflow: hidden;
clear: both;
}
.breadcrumb-list {
list-style: none;
background-color: #ffffff;
background-color: rgba(255, 255, 255, 0.5);
display: block;
float: left;
padding: 1em 50px;
pointer-events: auto;
}
.list-item {
display: inline-block;
}
<a id="total" href="#"></a>
<div class="no-pointer">
</div>
<div id="breadcrumb">
<ol class="breadcrumb-list">
<li class="list-item home-crumb">
<a class="crumb" href="#1">
<span>Home</span>
</a>
</li>
<li class="list-item">
<a class="crumb" href="#2">
<span>Test</span>
</a>
</li>
<li class="list-item">
<a class="crumb" href="#3">
<span>Test 2</span>
</a>
</li>
</ol>
</div>
All I have to add to this is... stupid IE! Grrrrr!
I've got a drop down menu that won't appear over the rest of the content. I've set the position to absolute and the z-index to 99 and no luck. Any ideas how to get it to lay on top of the rest of the site?
<body>
<header>
<div class="container">
<h1 class="logo">Relaxr</h1>
<nav>
</span>
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
<li>Blog</li>
</ul>
</nav>
</div>
</header>
<section id="main">
<div class="container">
nav {
position: relative;
}
nav ul {
display: none;
}
header {
margin-left: -20px;
margin-right: -20px;
}
body {
margin-left: 20px;
margin-right: 20px;
}
.container {
width: 100%;
margin: 0;
}
#main {
margin-top: 10px;
}
header nav ul li {
display: block;
margin-right: 20px;
margin: 0 20px 0 0;
}
.hamburger {
margin-top: 5px;
margin-right: 80px;
margin-bottom: 20px;
float:right;
position: relative;
display: inline-block;
width: 1.5em;
height: 0.74em;
border-top: 0.2em solid #fff;
border-bottom: 0.2em solid #fff;
}
.hamburger:before {
content: "";
position: absolute;
top: 0.9em;
left: 0px;
width: 100%;
border-top: 0.2em solid #fff;
}
nav ul {
position: absolute;
left: 0; top: 100%;
width: 100%;
background-color: black;
z-index: 99;
Codepen:
http://codepen.io/kiddigit/pen/wWvPJm
In your #media query change
nav {
position: relative;
}
to
nav {
position: absolute;
}
This will keep your menu on top.
I think You should use something like this to work
$(".hamburger").click(function(e){
$("nav > ul").toggle();
});
there is only one difference I've added a closing bracket in
$("nav > ul").toggle();
I have a Horizontal Menu. When the mouse is hovered over the child elements it disappears. The child elements cannot be clicked. I would like the child elements to stay when the mouse is hovered over it.
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 70px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>
It's because you have positioned your submenu absolutely, and it's too far away from your parent li, so your mouse is leaving the parent menu before it reaches the submenu. I've added borders to show you.
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
border: 1px solid blue;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 70px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>
You have padding, but it's on your a element, and needs to be on your li element, instead. Either add padding-top to your submenu li elements or adjust their top position so that they're directly underneath (aka "touching") the parent element.
Here is the code with the menu moved to top: 40px and the padding added to the submenu li elements:
.header {
color: #FFFFFF;
height: 60px;
width: 100%;
margin: auto;
}
.header_logo {
width: 40%;
height: 100%;
float: left;
}
#logo {
height: 100%;
top: 0;
left: 0;
width: 50%;
}
.header_title {
width: 60%;
float: left;
}
#titles {
position: absolute;
top: 20px;
font-family: "Times New Roman", Times, serif, Georgia;
font-size: 97%;
color: #B8B8B8;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
}
a {
text-decoration: none;
color: inherit;
padding: 21px 10px;
}
li ul li {
padding: 21px 10px;
}
li a:hover {
background-color: #666699;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
position: absolute;
width: 100%;
top: 40px;
left: 0;
white-space: nowrap;
}
* {
border: 0;
margin: 0;
padding: 0;
}
.content {
height: 800px;
margin: auto;
background-color: #C0C0C0;
}
.footer {
margin: auto;
background-color: #000000;
}
<div class="header">
<div class="header_logo">
<img id="logo" src="civic-logo.jpg">
</div>
<div class="header_title">
<div id="titles">
<ul>
<li>PRODUCTS
<ul>
<li>CEMENT</li>
<li>STEEL</li>
<li>BRICKS</li>
<li>SAND</li>
</ul>
</li>
<li>CONTACT US </li>
</ul>
</div>
</div>
</div>
<div class="content">
</div>
<div class="footer">
</div>