Created
December 22, 2023 15:05
-
-
Save kidkai25/4795fd364a7075c4866c27f224098df9 to your computer and use it in GitHub Desktop.
CSS Positions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="parent"> | |
<div id="c1"> </div> | |
<div id="c2"> </div> | |
<div id="c3"> </div> | |
<div id="c4"> </div> | |
<div id="c8">Test Div</div> | |
<div id="c5"> </div> | |
<div id="c6"> </div> | |
<div id="c7"> </div> | |
<div style="height:500px; background-color:grey">Rest</div> | |
</div> | |
<button id="pos-rel-btn">Relative Position</button> | |
<button id="pos-abs-btn">Absolute Position</button> | |
<button id="pos-fix-btn">Fixed Position</button> | |
<button id="pos-sticky-btn">Sticky Position</button> | |
<button id = "pos-static-btn">Static Position</button> | |
<span id="sp">Current Selected Position:</span> | |
<label id="current">NAN</label> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import $ from "https://esm.sh/jquery"; | |
$("#pos-rel-btn").click(function(){ | |
$("#c8").removeClass().addClass("pos-rel-class"); | |
$("#current").html("Relative"); | |
}); | |
$("#pos-abs-btn").click(function(){ | |
$("#c8").removeClass().addClass("pos-abs-class"); | |
$("#current").html("Absolute"); | |
}); | |
$("#pos-fix-btn").click(function(){ | |
$("#c8").removeClass().addClass("pos-fix-cls"); | |
$("#current").html("Fixed"); | |
}); | |
$("#pos-sticky-btn").click(function(){ | |
$("#c8").removeClass().addClass("pos-sticky-cls"); | |
$("#current").html("Sticky"); | |
}); | |
$("#pos-static-btn").click(function(){ | |
$("#c8").removeClass().addClass("pos-static-cls"); | |
$("#current").html("Static(Default)"); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#c1{ | |
background-color:red; | |
} | |
#c2{ | |
background-color:orange; | |
} | |
#c3{ | |
background-color:yellow; | |
} | |
#c4{ | |
background-color:green; | |
} | |
#c5{ | |
background-color:blue; | |
} | |
#c6{ | |
background-color:indigo; | |
} | |
#c7{ | |
background-color:violet; | |
} | |
#c8{ | |
background-color:black; | |
color:white; | |
width:100px; | |
} | |
#pos-rel-btn | |
{ | |
position: absolute; | |
top: 400px; | |
left: 250px; | |
} | |
#pos-abs-btn{ | |
position: absolute; | |
top:400px; | |
left: 100px; | |
} | |
#pos-fix-btn{ | |
position: absolute; | |
top:350px; | |
left: 100px; | |
} | |
#pos-sticky-btn{ | |
position: absolute; | |
top:350px; | |
left: 250px; | |
} | |
#pos-static-btn{ | |
position: absolute; | |
top:350px; | |
left: 400px; | |
} | |
.pos-rel-class{ | |
position:relative; | |
top: 100px; | |
} | |
.pos-abs-class{ | |
position:absolute; | |
top:10px; | |
} | |
.pos-fix-cls{ | |
position:fixed; | |
top:10px; | |
} | |
.pos-sticky-cls{ | |
position: sticky; | |
top:10px; | |
left:40px; | |
} | |
.pos-static-cls | |
{ | |
position: static; | |
} | |
#current | |
{ | |
position: absolute; | |
top:300px; | |
left:275px; | |
} | |
#sp | |
{ | |
position: absolute; | |
top:300px; | |
left:80px; | |
} | |
.parent{ | |
height: 2000px; | |
} | |
.ht{ | |
height: 50px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Css positions testing.