How to transform/transition div without moving the text? - css

I created an overlay menu for the responsive menu of website. every thing is OK but when the menu will be closed, the texts (in menu) will be gathered and moved individually and then disappear but I want them to slide out without moving texts.
I tried these HTML:
<section class="overlaysection">
<div id="myoverlaynav" class="overlay">
×
<div class="overlay-content">
<li><a>num one one one one</a></li>
<li><a>num two two two two</a></li>
<li><a>num three three three three</a></li>
<li><a>num four four four four four</a></li>
</div>
</div>
<div class="overlaybtndiv" onclick="openNav()">
<button class="overlaybtn">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<h2>The Menu</h2>
</div>
</section>
CSS Codes:
#media (min-width: 631px){
.overlaysection {
display: none;
}
}
.overlaysection .overlay {
height: 100%;
width: 0;
position: fixed;
/* z-index: 1; */
z-index: 999999;
top: 0;
left: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.9);
overflow-x: hidden;
transition: 0.5s;
direction:rtl;
}
.overlaysection a.closebtn {
position: absolute;
font-size: 40px;
padding: 0;
line-height: 40px;
top: 10px;
right: 10px;
color: #eee;
}
.overlaysection .overlay-content {
position: relative;
width: 100%;
text-align: center;
margin-top: 40px;
}
.overlaysection .overlay a {
display: block;
transition: 0.3s;
text-align: left;
color: #eee;
padding: 8px 8px 8px 20px;
text-decoration: none;
}
.overlaysection .overlay a:hover,
.overlaysection .overlay a:focus {
color: #f1f1f1;
}
.overlaysection .overlaybtndiv {
display: block;
padding: 6px 8px;
position: relative;
}
.overlaysection .overlaybtndiv h2 {
font-size: 14px;
color: black;
line-height: 40px;
margin-right: 10px;
}
.overlaysection .overlaybtn {
border-color: transparent !important;
float: right;
padding: 5px;
background: white;
outline: 0;
}
.overlaysection .overlaybtn .icon-bar {
display: block;
height: 2px;
border-radius: 1px;
padding: 1.5px;
width: 28px;
background-color: black !important;
margin-top: 5px;
}
.overlaysection .overlaybtn .icon-bar:first-child {
margin-top: 3px !important;
}
.
javascript codes:
function openNav() {
document.getElementById("myoverlaynav").style.width = "80%";
}
function closeNav() {
document.getElementById("myoverlaynav").style.width = "0%";
}
you can see this menu in https://end-eng.com/grammar/auxiliary-modal-verbs-in-english/ and this menu is like https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_sidenav

Add min-width and float:left to .overlay-content.
.overlaysection .overlay-content {
position: relative;
width: 100%;
text-align: center;
margin-top: 50px;
min-width: 270px;
float: left;
}

right now what happening is when close navbar its width is reduced so thus your li tag width to so, just give your li tag fixed width and your problem will be solved like.
#media (min-width: 631px){
.li {
width : 200px;
}
}
and only give this in media query for smaller devices otherwise it will replicate in whole website.

It's because you're using width's to control the display.
Instead of this, I suggest that you toggle a "shown" class to your overlay.
By default on your ".overlaysection .overlay" css, change the width to 100% and left to -100%;
Then on the "shown" class set the left to 0. Change the JS to toggle the
shown class and it should then slide out from the left without changing the text orientation.
function openNav() {
document.getElementById("myoverlaynav").classList.toggle('shown');
}
function closeNav() {
document.getElementById("myoverlaynav").classList.toggle('shown');
}
#media (min-width: 631px){
.overlaysection {
display: none;
}
}
.overlaysection .overlay {
height: 100%;
width: 100%;
position: fixed;
/* z-index: 1; */
left: -100%;
z-index: 999999;
top: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.9);
overflow-x: hidden;
transition: 0.5s;
direction:rtl;
}
.overlaysection a.closebtn {
position: absolute;
font-size: 40px;
padding: 0;
line-height: 40px;
top: 10px;
right: 10px;
color: #eee;
}
.overlaysection .overlay-content {
position: relative;
width: 100%;
text-align: center;
margin-top: 40px;
}
.overlaysection .overlay a {
display: block;
transition: 0.3s;
text-align: left;
color: #eee;
padding: 8px 8px 8px 20px;
text-decoration: none;
}
.overlaysection .overlay a:hover,
.overlaysection .overlay a:focus {
color: #f1f1f1;
}
.overlaysection .overlaybtndiv {
display: block;
padding: 6px 8px;
position: relative;
}
.overlaysection .overlaybtndiv h2 {
font-size: 14px;
color: black;
line-height: 40px;
margin-right: 10px;
}
.overlaysection .overlaybtn {
border-color: transparent !important;
float: right;
padding: 5px;
background: white;
outline: 0;
}
.overlaysection .overlaybtn .icon-bar {
display: block;
height: 2px;
border-radius: 1px;
padding: 1.5px;
width: 28px;
background-color: black !important;
margin-top: 5px;
}
.overlaysection .overlaybtn .icon-bar:first-child {
margin-top: 3px !important;
}
#myoverlaynav.shown {
left: 0;
}
<section class="overlaysection">
<div id="myoverlaynav" class="overlay">
×
<div class="overlay-content">
<li><a>num one one one one</a></li>
<li><a>num two two two two</a></li>
<li><a>num three three three three</a></li>
<li><a>num four four four four four</a></li>
</div>
</div>
<div class="overlaybtndiv" onclick="openNav()">
<button class="overlaybtn">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<h2>The Menu</h2>
</div>
</section>

Related

Text input - can't align text top or bottom, only center

folks! I'm trying to align the text inside a text form input to be next to the line at the bottom, but it doesn't quite concede, insisting on being center aligned.
I've put some vertical-align: bottom on different elements, but it didn't work (it's on the code below).
Here is the codepen: https://codepen.io/ironsand-sou-eu/pen/zYEmEdw
HTML:
<div class="form-input field">
<input type="text" name="my_input" id="my_input" value="I'd love to be a little closer to the line below! Can you help me?">
<label for="my_input" data-title="Just some label"></label>
</div>
CSS:
.form-input {
width: 100%;
background-color: transparent;
border-bottom: 1px green solid;
border-top: none;
border-right: none;
border-left: none;
}
.form-input::before {
content: '';
position: absolute;
background-color: green;
left: 0;
bottom: 0;
width: 0;
height: 2px;
transition: ease-out 300ms;
}
.form-input:hover::before {
width: 100%;
}
.form-input:focus-within::before {
width: 100%;
}
.form-input input {
border: none;
width: 100%;
}
.form-input input:focus-visible {
outline: none;
}
.field {
position: relative;
margin-bottom: 15px;
vertical-align: bottom;
}
.field label::before {
content: attr(title);
position: absolute;
top: 0;
left: 15px;
line-height: 40px;
font-size: 14px;
color: #777;
transition: 300ms all;
}
.field input {
width: 100%;
line-height: 40px;
padding: 0 8px;
box-sizing: border-box;
font-size: 14px;
color: green;
vertical-align: bottom;
}
Place this at the bottom of the CSS section:
input[type=text] {
height: 15px;
}

Dynamic circle navigation menu

Here are the requirements:
Hover effect when any of the ‘Navigation’ sections (Navigation 1,
Navigation 2, Navigation 3) is selected.
Click effect when any of the ‘Navigation’ sections (Navigation 1,
Navigation 2, Navigation 3) is selected. If Navigation 1 is clicked,
it will go to another page, same as Navigation 2 and Navigation 3.
I have searched high and low for an example, and all of the search results points to using css, but this requires manually figuring out the position of the items.
.text
{
cursor:pointer;
}
.circle {
position: relative;
border: 0px;
padding: 0;
margin: 1em auto;
width: 430px;
height: 430px;
border-radius: 50%;
list-style: none;
overflow: hidden;
}
li {
overflow: hidden;
position: absolute;
top: -20%;
right: -20%;
width: 70%;
height: 70%;
transform-origin: 0% 100%;
}
.text {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
text-align: center;
transform: skewY(-60deg) rotate(15deg);
padding-top: 20px;
}
li:first-child {
transform: rotate(0deg) skewY(30deg);
border-left: 8px solid #fff;
border-right: 8px solid #fff;
}
li:nth-child(2) {
transform: rotate(120deg) skewY(30deg);
border-right: 8px solid #fff;
border-left: 8px solid #fff;
}
li:nth-child(3) {
transform: rotate(240deg) skewY(30deg);
border-right: 8px solid #fff;
border-left: 8px solid #fff;
}
li:first-child .text {
background: green;
}
li:nth-child(2) .text {
background: tomato;
}
li:nth-child(3) .text {
background: aqua;
}
li:nth-child(3) .text:hover {
background-color: #a5e2f3;
}
li:nth-child(2) .text:hover {
background-color: #86d8ef;
}
li:nth-child(1) .text:hover {
background-color: #66ceeb;
}
.cn-button {
position: absolute;
top: 40%;
left: 50%;
z-index: 11;
margin-top: -2.25em;
margin-left: -2.25em;
padding-top: 0;
width: 4.5em;
height: 4.5em;
border: 1px solid;
border-radius: 50%;
background: none;
background-color: yellow;
color: yellow;
text-align: center;
font-weight: 700;
font-size: 1.5em;
text-transform: uppercase;
cursor: pointer;
-webkit-backface-visibility: hidden;
}
.icon {
position: absolute;
/* exact values here depend on what you are placing inside the items (icon, image, text, etc.) */
top: 40%;
/* make sure it it rotated enough; angle of rotation = angle of the sector itself */
transform: rotate(224deg);
/* style further as needed */
color: #fff;
font-family: Indie Flower;
font-size: 25px;
}
<button class="cn-button" id="cn-button"></button>
<ul class="circle">
<li>
<a class="one" href="circle.html">
<div class="text" ><span class="icon">Navigation 1</span></div>
</a>
</li>
<li>
<a class="two" href="circle2.html">
<div class="text"><span class="icon">Navigation 2</span></div>
</a>
</li>
<li>
<a class="three" href="circle3.html">
<div class="text"><span class="icon">Navigation 3</span></div>
</a>
</li>
</ul>
i want exact like .
How can I create a menu like this where I can dynamically add items?

Pagination with extra space

I have some pagination in a div and am seeing some extra space. I'm not sure where it is coming from. The extra space is green (I added a background to the container).
The URL is: http://joshrodg.com/test/inductees/page/2/
Basically, at the bottom of the page, you'll see the pagination. The code is generated, so I can't change that. I'm pretty sure it's something with the css adding the extra space.
I can put a height on the wrap and the extra space goes away, but that's cheating.
The HTML looks like:
<div id="pagi">
<div class="wrap">
<a class="prev page-numbers" href="http://joshrodg.com/test/inductees/"><span class="left"></span><span class="ion-android-arrow-dropleft"></span> Prev</a>
<a class="page-numbers" href="http://joshrodg.com/test/inductees/">1</a>
<span aria-current="page" class="page-numbers current">2</span>
<a class="page-numbers" href="http://joshrodg.com/test/inductees/page/3/">3</a>
<a class="page-numbers" href="http://joshrodg.com/test/inductees/page/4/">4</a>
<span class="page-numbers dots">…</span>
<a class="page-numbers" href="http://joshrodg.com/test/inductees/page/15/">15</a>
<a class="next page-numbers" href="http://joshrodg.com/test/inductees/page/3/">Next <span class="ion-android-arrow-dropright"></span><span class="right"></span></a>
</div>
</div>
The CSS looks like:
#pagi {
text-align: center;
}
#pagi .wrap {
background: #00ff00;
display: inline-block;
font-size: 0;
overflow: hidden;
position: relative;
}
#pagi .page-numbers {
background: #CD1F31;
display: inline-block;
color: #fff;
font-family: 'Lato', sans-serif;
font-size: 18px;
line-height: 40px;
padding: 0 10px;
position: relative;
text-decoration: none;
top: -2px;
}
#pagi .current {
background: #fff;
color: #CD1F31;
}
#pagi .next,
#pagi .prev {
background: #054872;
color: #fff;
font-family: 'Oswald', sans-serif;
font-size: 20px;
line-height: 40px;
position: relative;
text-transform: uppercase;
top: 0;
}
#pagi .next {
padding: 0 35px 0 16px;
}
#pagi .prev {
padding: 0 16px 0 35px;
}
#pagi .left,
#pagi .right {
background: #333;
border-bottom: 21px solid transparent;
border-top: 21px solid transparent;
height: 0;
position: absolute;
top: 0;
width: 0;
}
#pagi .left {
border-right: 12px solid #054872;
left: 0;
}
#pagi .right {
border-left: 12px solid #054872;
right: 0;
}
#pagi .ion-android-arrow-dropleft,
#pagi .ion-android-arrow-dropright {
display: inline-block;
font-size: 30px;
position: absolute;
top: 6px;
}
pagi .ion-android-arrow-dropleft {
left: 18px;
}
#pagi .ion-android-arrow-dropright {
right: 18px;
}
#pagi a:hover .ion-android-arrow-dropleft,
#pagi a:hover .ion-android-arrow-dropright {
color: #fff;
}
#pagi a:hover {
color: #ddd;
}
I know this is probably something simple that I'm over-looking. If someone could point me in the right direction I'd appreciate it!
The one thing I forgot to mention is everything works just fine when the fonts are the same - my guess is the size differences are causing some of the issues.
Thanks,
Josh
So, after investigating this issue further, my problem was being creating by the different Google Web Fonts I was using.
The page numbers use a font called Lato and the Previous and Next links use a font called Oswald.
Somehow the line heights and padding that both fonts had were conflicting and I couldn't get them to play nicely with each other.
Both the Previous and Next links and the page numbers have the same pagenumbers class assigned. Because this is generated code, that's something I can't change.
So, I removed the Oswald font, which fixed the issue...unfortunately, I wanted the font to be different, so I was thinking about other options available visually.
I also had some arrows next to the Previous and Next links. Those arrows were absolutely positioned, so none of the line height issues apply.
After thinking it over I decided to go with arrows-only!
Now, the alignment is fixed and I understand what happened.
The HTML remains unchanged:
<div id="pagi">
<div class="wrap">
<a class="prev page-numbers" href="http://joshrodg.com/test/inductees/"><span class="left"></span><span class="ion-android-arrow-dropleft"></span> Prev</a>
<a class="page-numbers" href="http://joshrodg.com/test/inductees/">1</a>
<span aria-current="page" class="page-numbers current">2</span>
<a class="page-numbers" href="http://joshrodg.com/test/inductees/page/3/">3</a>
<a class="page-numbers" href="http://joshrodg.com/test/inductees/page/4/">4</a>
<span class="page-numbers dots">…</span>
<a class="page-numbers" href="http://joshrodg.com/test/inductees/page/15/">15</a>
<a class="next page-numbers" href="http://joshrodg.com/test/inductees/page/3/">Next <span class="ion-android-arrow-dropright"></span><span class="right"></span></a>
</div>
</div>
The CSS looks like:
#pagi {
margin: 5px 20px 25px;
text-align: center;
}
#pagi .wrap {
background: #054872;
display: inline-block;
font-size: 0;
overflow: hidden;
position: relative;
}
#pagi .page-numbers {
background: #CD1F31;
display: inline-block;
color: #fff;
font-family: 'Lato', sans-serif;
font-size: 18px;
line-height: 40px;
padding: 0 10px;
text-decoration: none;
}
#pagi .current {
background: #fff;
color: #CD1F31;
}
#pagi .next,
#pagi .prev {
color: #fff;
text-transform: uppercase;
}
#pagi .next {
padding: 0 25px 0 16px;
}
#pagi .prev {
padding: 0 16px 0 25px;
}
#pagi .left,
#pagi .right {
background: #333;
border-bottom: 21px solid transparent;
border-top: 21px solid transparent;
height: 0;
position: absolute;
top: 0;
width: 0;
}
#pagi .left {
border-right: 12px solid #054872;
left: 0;
}
#pagi .right {
border-left: 12px solid #054872;
right: 0;
}
#pagi .ion-android-arrow-dropleft,
#pagi .ion-android-arrow-dropright {
display: inline-block;
font-size: 30px;
position: absolute;
top: 6px;
}
#pagi .ion-android-arrow-dropleft {
left: 18px;
}
#pagi .ion-android-arrow-dropright {
right: 18px;
}
#pagi a:hover .ion-android-arrow-dropleft,
#pagi a:hover .ion-android-arrow-dropright {
color: #fff;
}
#pagi a:hover {
color: #ddd;
}
There are other ways I could've fixed this. I could've specified a width and absolutely positioned my Previous and Next links, which would also fix this issue because of the absolute positioning.
But, I like this solution and think it is better to just not have the inferred Previous and Next links and just show the icons (pointing in their respective directions).
Thanks,
Josh

Bootstrap HTML5 Title with border and small text like fieldset but no fieldset/legend

I am building bootstrap based web and I am trying to make title inside of a frame with text attached in the middle of bottom border and still be responsive. Small text on small devices can go in multiple rows, or even go inside the box.
All I could do is. And I want to do it like .
I hope someone already done this and/or could help me doing it.
Thanks in advance.
One big detail is it should be completely transparent so it can go over a backround picture.
And it is much differend than fieldset because the "legend" is on bottom.
Update:
See fiddle
CSS:
.navbar-brand {
margin: 0;
color: #ffffff;
text-align: center;
position: relative;
display: inline-block;
border-top: 8px solid #ffffff;
padding: 5px 32px 0px 32px;
line-height: 1.08333333;
height: auto;
}
.navbar-brand:before {
position: absolute;
content: '';
left: -8px;
top: -8px;
width: 8px;
bottom: 12px;
background: #ffffff;
}
.navbar-brand:after {
position: absolute;
content: '';
right: -8px;
top: -8px;
width: 8px;
bottom: 12px;
background: #ffffff;
}
.navbar-brand a:hover,
.navbar-brand a:focus {
color: #ffffff;
text-decoration: none;
}
.navbar-header + h3 {
margin-top: 61px;
}
.navbar-header {
text-align: center;
}
.small-lines:before {
position: absolute;
content: '';
left: -40px;
height: 8px;
bottom: 12px;
width: 8%;
background: #ffffff;
}
.small-lines:after {
position: absolute;
content: '';
right: -40px;
height: 8px;
bottom: 12px;
width: 8%;
background: #ffffff;
}
.small-lines1:before {
width: 38%;
background: #009fb6;
}
.small-lines1:after {
width: 38%;
background: #009fb6;
}
.navbar-brand a{
font-size: 48px;
}
.container{
margin-top: 150px;
}
small {
line-height: 1.2;
font-size: 24px;
letter-spacing: 4.8px;
display: block;
position: relative;
}
HTML:
<body style="background: black">
<header class="">
<div class="container text-center">
<div class="navbar-header">
<h1 class="navbar-brand ">
<a href="./">BIG TITLE ONE<br>
<small class="small-lines">Here comes small text</small>
</a>
</h1>
</div>
</div>
</header>
</body>

Lower z-index overlaps higher

This is my HTML structure:
<div class="pageSlider">
Visitor's Lounge
News Stream
<a class="slide-button"></a>
</div>
And here are my CSS rules:
.pageSlider {
margin: 15px auto !important;
font-size: 1.2em;
white-space: nowrap;
height: 35px;
}
.pageSlider a[href] {
display: inline-block;
text-align: center;
text-decoration: none;
z-index: 2;
}
.pageSlider a[href].active {
color: #000;
}
.pageSlider .slide-button {
background-color: #cccc00;
position: relative;
top: -35px;
display: inline-block;
height: 35px;
padding: 0;
float: left;
height: inherit;
z-index: 1;
}
The .pageSlider .slide-button is set to z-index: 1 and .pageSlider a[href] is set to z-index: 2, but the lower z-index actually overlaps the higher.
I somehow need toget the .slide-button under the links, but I can't seem to figure out a better way.
Live demo:
(function(e){e.parseURL=function(e){if(typeof e==="undefined"&&typeof window.location.href!=="undefined")e=window.location.href;var t={whole:/^((http|https):\/\/)?((.*\.)?.*\..*|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\/.*/,protocol:/^(http|https):\/\//,absolute:/^\/\/((.*\.)?.*\..*|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\//,relative:/^[\/](?!\/).*(\..*|\/)?.*$/,params:/\?.*=.*(\&.*\=.*)+[^#.*]/},n={protocol:undefined,hostname:undefined,hash:undefined,href:{original:undefined,noparams:undefined},parentDomain:undefined,parameters:undefined,pathname:{nohash:undefined,withhash:undefined},type:undefined};if(typeof e!=="string")throw new TypeError("Argument must be a string!");else if(!t.whole.test(e)&&!t.absolute.test(e)&&!t.relative.test(e))throw new Error("Invalid string");n.href.original=e;if(e.indexOf("#")!==-1){n.hash=e.substring(e.indexOf("#"));e=e.substring(0,e.indexOf("#"))}if(t.params.test(e)){n.parameters={};var r=e.match(t.params)[0].substring(1).split("&");for(var i=0,s=r.length;i<s;i++){var o=r[i].split("=");n.parameters[o[0]]=o[1]}e=e.replace(t.params,"");n.href.noparams=e+(typeof n.hash!=="undefined"?n.hash:"")}if(t.protocol.test(e)){n.protocol=e.match(t.protocol)[0];n.hostname=e.replace(t.protocol,"");n.hostname=n.hostname.substring(0,n.hostname.indexOf("/"));n.parentDomain=n.hostname.split(".");n.parentDomain.splice(0,1);n.parentDomain=n.parentDomain.join(".");if(n.parentDomain=="")n.parentDomain=n.hostname;var u=e.replace(t.protocol,"");n.pathname.nohash=u.substring(u.indexOf("/"));u=undefined;n.type="normal"}else{n.protocol=window.location.href.match(t.protocol)[0];if(t.absolute.test(e)){var u=e.replace(/^\/\//,"");n.hostname=u.substring(0,u.indexOf("/"));n.pathnam.nohashe=u.substring(u.indexOf("/"));n.type="absolute";n.href.original=n.href.original.replace(/^\/\//g,n.protocol)}else if(t.relative.test(e)){n.hostname=window.location.href.replace(t.protocol,"");n.hostname=n.hostname.substring(0,n.hostname.indexOf("/"));n.pathname.nohash=n.href.original;n.type="relative"}else{throw new Error("Invalid string")}}n.pathname.withhash=n.pathname.nohash+n.hash;return n};if(typeof e(".pageSlider")[0]!=="undefined"){e.pageSlider=function(t){if(t==="update"){e('.pageSlider a.active:not([href="'+e.parseURL().hash+'"])').removeClass("active");e('.pageSlider a[href="'+e.parseURL().hash+'"]').addClass("active");e(".pageSlider").each(function(){var t=e(this);var n=t.find("a.slide-button");var r=t.find("a[href]");var i=r.size();var s=100/i;var o=r.index("a.active");r.css("width",s+"%");console.log(o);n.css("width",s+"%").animate({left:o*-1*s+"%"})});return e('.pageSlider a.active[href="'+e.parseURL("/index.php").hash+'"]')}};window.location.hash="lounge";e.pageSlider("update");e(window).on("hashchange",function(){e.pageSlider("update")})}})(jQuery)
.pageSlider {
margin: 15px auto !important;
font-size: 1.2em;
white-space: nowrap;
height: 35px;
}
.pageSlider a[href] {
display: inline-block;
text-align: center;
text-decoration: none;
color: #fff;
z-index: 2;
}
.pageSlider a[href].active {
color: #000;
}
.pageSlider .slide-button {
background-color: #cccc00;
position: relative;
top: -35px;
display: inline-block;
padding: 0;
float: left;
height: inherit;
z-index: 1;
}
body{background-color:#777}#media all and (max-width: 500px){.pageSlider{white-space: normal}.pageSlider a[href]{display: block !important;width: 100% !important}.pageSlider [href].active {background-color: #cccc00}.pageSlider .slide-button{display: none}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pageSlider">
Visitor's Lounge
News Stream
<a class="slide-button"></a>
</div>
You forgot to add:
position:relative;
on your link (.pageSlider a[href]). z-index only applies to positioned elements.

Resources