Hello its me again i have a problem... You see i got a div inside another div and that div got text in it.. However when i position my second div to the right in my big div the text gets positioned right aswell... And I am not able to move it back with left:0 it works with left:-250px but that aint a good solution.... how should I achieve this?
#spellista {
background-color: green;
position: absolute;
right: 0;
width: 29%;
height: 100%;
top: 0;
}
#first {
left: 0 !important;
position: absolute;
}
.second {
color: red;
}
.third {
color: blue;
}
#searchBar {
height: 80%;
width: 85%;
background-color: rgba(32, 32, 45, 0.98);
position: fixed;
top: 10%;
left: 0;
z-index: 2;
margin: auto;
top: 0;
right: 0;
bottom: 0;
border-radius: 5px;
z-index: 3;
}
<div id="searchBar">
<div id="spellista">
<ul id='first'>
<li class="second">MOre TEXT</li>
<li class="third">TEXT</li>
</ul>
</div>
</div>
remove duplicate id's
#spellista {
background-color: green;
position: absolute;
right: 0;
width: 29%;
height: 100%;
top: 0;
}
#first {
left: 0 !important;
position: absolute;
}
.second {
color: red;
}
.third {
color: blue;
}
#searchBar {
height: 80%;
width: 85%;
background-color: rgba(32, 32, 45, 0.98);
position: fixed;
top: 10%;
left: 0;
z-index: 2;
margin: auto;
top: 0;
right: 0;
bottom: 0;
border-radius: 5px;
z-index: 3;
}
<div id="searchBar">
<div id="spellista">
<div id="spellista1">
<ul id='first'>
<li class="second">MOre TEXT</li>
<li class="third">TEXT</li>
</ul>
</div
</div>
</div>
Your css code is Ok , Only change Html Code (you have multiple elements with same id) :
Your Code is :
<div id="searchBar">
<div id="spellista">
<div id="spellista">
<ul id='first'>
<li class="second">MOre TEXT</li>
<li class="third">TEXT</li>
</ul>
</div
</div>
</div>
Change To :
<div id="searchBar">
<div id="spellista">
<ul id='first'>
<li class="second">MOre TEXT</li>
<li class="third">TEXT</li>
</ul>
</div>
</div>
Full code:
#spellista{
background-color: green;
position: absolute;
right: 0;
width: 29%;
height: 100%;
top: 0;
}
#first{
left:0 !important;
position:absolute;
}
.second{
color:red;
}
.third{
color:blue;
}
#searchBar{
height:80%;
width:85%;
background-color:rgba(32, 32, 45, 0.98);
position:fixed;
top: 10%;
left: 0;
z-index:2;
margin: auto;
top: 0;
right: 0;
bottom: 0;
border-radius:5px;
z-index:3;
}
<div id ="searchBar">
<div id = "spellista">
<ul id = 'first'>
<li class = "second">MOre TEXT</li>
<li class = "third">TEXT</li>
</ul>
</div>
</div>
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%;
}
}
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.
In yellow square I have a hover effect, but when hover display the higher the green block. I need what would be the hover effect of only at yellow square.
I tried to use z-index - did not help.
What am I doing wrong?
*{
padding: 0;
margin: 0;
}
.wrapper {
border:2px solid black;
margin-top: 20px;
padding: 20px 20px;
height: 100%;
}
.block__one {
background-color:green;
z-index:5;
position: relative;
}
.item {
padding: 10px;
margin: 0;
text-align:center;
}
.list {
display: inline-block;
width: 50px;
height: 40px;
background-color:yellow;
position: relative;
z-index:10;
}
.list:hover .list__hover {
opacity:1;
bottom:0;
}
.list__hover {
width: 100%;
height: 50%;
background-color: #fff;
position: absolute;
bottom:-50px;
transition: bottom 0.5s;
opacity:0;
z-index:4;
}
.block__two {
background-color:red;
width: 100%;
height: 200px;
z-index:5;
position: relative;
}
<div class="wrapper">
<div class="block__one">
<ul class="item">
<li class="list">
<div class="list__hover"></div>
</li>
<li class="list">
<div class="list__hover"></div>
</ul>
</div>
<div class="block__two"></div>
</div>
I'm not certain I've 100% understood your post, but I believe that all you need is to add
overflow:hidden
to the .list class
Check if the snippet is doing what you want:
*{
padding: 0;
margin: 0;
}
.wrapper {
border:2px solid black;
margin-top: 20px;
padding: 20px 20px;
height: 100%;
}
.block__one {
background-color:green;
z-index:5;
position: relative;
}
.item {
padding: 10px;
margin: 0;
text-align:center;
}
.list {
display: inline-block;
width: 50px;
height: 40px;
background-color:yellow;
position: relative;
z-index:10;
overflow:hidden;
}
.list:hover .list__hover {
opacity:1;
bottom:0;
}
.list__hover {
width: 100%;
height: 50%;
background-color: #fff;
position: absolute;
bottom:-50px;
transition: bottom 0.5s;
opacity:0;
z-index:4;
}
.block__two {
background-color:red;
width: 100%;
height: 200px;
z-index:5;
position: relative;
}
<div class="wrapper">
<div class="block__one">
<ul class="item">
<li class="list">
<div class="list__hover"></div>
</li>
<li class="list">
<div class="list__hover"></div>
</ul>
</div>
<div class="block__two"></div>
</div>
Here's another solution using first height of 0% and then transitioning it to 50%. Also check your code, there's a few mistakes in it. You could, for example, use W3 validator.
* {
padding: 0;
margin: 0;
}
.wrapper {
border: 2px solid black;
margin-top: 20px;
padding: 20px 20px;
height: 100%;
}
.block__one {
background-color: green;
z-index: 5;
position: relative;
}
.item {
padding: 10px;
margin: 0;
text-align: center;
}
.list {
display: inline-block;
width: 50px;
height: 40px;
background-color: yellow;
position: relative;
z-index: 10;
}
.list:hover .list__hover {
opacity: 1;
bottom: 0px;
height: 50%;
transition: linear .5s;
}
.list__hover {
width: 100%;
height: 0%;
background-color: #fff;
position: absolute;
bottom: 0px;
opacity: 0;
z-index: 4;
}
.block__two {
background-color: red;
width: 100%;
height: 200px;
z-index: 5;
position: relative;
}
<div class="wrapper">
<div class="block__one">
<ul class="item">
<li class="list">
<div class="list__hover"></div>
</li>
<li class="list">
<div class="list__hover"></div>
</li>
</ul>
</div>
<div class="block__two"></div>
</div>
So I have an image. I need to put a color overlay rgba(56, 59, 64, 0.7) on top of this image.
HTML:
<div class="home">
<img src="http://via.placeholder.com/350x150" />
</div>
CSS:
.home img {
width: 100%;
padding: 0;
margin: 0;
}
.home img {
width: 100%;
padding: 0;
margin: 0;
}
<div class="home">
<img src="http://via.placeholder.com/350x150" />
</div>
Here you go
.home {
}
img {
width: 100%;
padding: 0;
margin: 0;
display:block;
}
.wrap {
position:relative;
}
.wrap:before {
content:"";
position: absolute;
top:0;
left:0;
height:100%;
width:100%;
background: rgba(0,0,0,0.5);
z-index:999;
}
<div class="home">
<div class="wrap">
<img src="http://via.placeholder.com/350x150" />
</div>
</div>
You can use pseudo-elements like before and absolute position it on top of the image
Added a blue background color for example purposes , so you can see it better, but you can use any color with opacity
img {
width: 100%;
padding: 0;
margin: 0;
}
.home {
position:relative;
}
.home:before {
content: "";
width: 100%;
height: 100%;
position: absolute;
background: rgba(0,0,255,0.5);
}
<div class="home">
<img src="http://via.placeholder.com/350x150">
</div>
HTML
<div class="home">
<img src="mango.jpg" />
<div class="overlay"></div>
</div>
SCSS
.home {
position: relative;
img {
max-width: 100%;
padding: 0;
margin: 0;
}
.overlay {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: rgba(56, 59, 64, 0.7);
}
}
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!