I'm making a webpage for a class, and have been instructed to make three divs that can be hidden and shown with a set of buttons at the top of the page. The buttons themselves work fine, however whenever I click on the third one the third div shows up as expected, but then i can't click on any of the buttons anymore.
What's supposed to happen is that I can click on any of the buttons to make the current div disappear and the one for the button I clicked appear, however instead once the third one shows up I can't click the buttons at all. I noticed that when I tried double clicking the buttons, it selected the image at the top of the third div, so I tried getting rid of the image, which made the buttons work again. I have to keep the image though, so I had to put it back, and then tried seeing if maybe the image was actually super big, just with most of it being empty and overlapping with the buttons, however when I put a border on it it showed the edges of the image were the expected size, and not covering the buttons at all, yet somehow it was still stopping me from clicking the button. I've tried setting the z-index to -1 and -10, neither worked, and setting pointer-events to none, which also didn't work. I've tried getting rid of some fiex position properties, but that made the div or top bar be drawn, in the div's case, too high, and in the bar's case, too thin, and with the buttons above it. My goal with the positioning is the have the div a bit below the bar at the top, with the picture centered inside it, and the bar having a little under about the height of the buttons worth of padding above and below the buttons. How might I fix this problem?
function toggle() {
var x = document.getElementById("myDIV");
var y = document.getElementById("myDIV2");
var z = document.getElementById("myDIV1");
if (x.style.display === "flex") {
x.style.display = "none";
y.style.display = "none";
z.style.display = "none";
} else {
x.style.display = "flex";
y.style.display = "none";
z.style.display = "none";
}
}
function toggle2() {
var x = document.getElementById("myDIV");
var y = document.getElementById("myDIV2");
var z = document.getElementById("myDIV1");
if (x.style.display === "flex") {
x.style.display = "none";
y.style.display = "none";
z.style.display = "none";
} else {
x.style.display = "none";
y.style.display = "flex";
z.style.display = "none";
}
}
function toggle1() {
var x = document.getElementById("myDIV");
var y = document.getElementById("myDIV2");
var z = document.getElementById("myDIV1");
if (x.style.display === "flex") {
x.style.display = "none";
y.style.display = "none";
z.style.display = "none";
} else {
x.style.display = "none";
y.style.display = "none";
z.style.display = "flex";
}
}
.LandingBar {
background: black;
position: fixed;
left: 0;
height: 13%;
width: 100%;
margin-top: 2.5%;
Opacity: 60%;
top: 20px;
}
.btn {
background: none;
opacity: 1;
border-radius: 10px;
border: 2px solid white;
cursor: pointer;
color: white;
font-family: Helvetica;
font-size: 1em;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
padding: 5px 10px 5px 10px;
}
.alignV {
position: relative;
top: 50%;
transform: translateY(-50%);
align-items: center;
justify-content: center;
}
.btn-space {
background: none;
opacity: 0;
width: 50px;
}
.btn:hover,
.btn:focus {
background-color: yellow;
color: black;
}
#myDIV {
position: fixed;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 100%;
text-align: center;
align-items: center;
justify-content: center;
padding: 1%;
/*background-color: lightblue;*/
flex-direction: row;
font-family: Helvetica;
display: none;
}
.myDIVbox {
position: relative;
left: 0;
/*border: 2px solid red;*/
width: 60%;
height: 50%;
padding-bottom: 30px;
padding-top: 30px;
display: inline-flex;
flex-direction: row;
font-family: Helvetica;
color: white;
background: black;
opacity: 60%;
padding-left: 30px;
padding-right: 30px;
flex-direction: column;
top: 80px;
}
.logo {
position: relative;
left: 310px;
/*border: 5px solid red;*/
}
.btn1 {
background: none;
opacity: 1;
border-radius: 10px;
border: 2px solid white;
cursor: pointer;
color: white;
font-family: Helvetica;
font-size: 1em;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
padding: 5px 10px 5px 10px;
width: 25%;
position: relative;
left: 290px;
}
#myDIV1 {
position: fixed;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 100%;
text-align: center;
align-items: center;
justify-content: center;
padding: 1%;
/*background-color: lightblue;*/
flex-direction: row;
font-family: Helvetica;
display: none;
}
.myDIVbox1 {
position: relative;
left: 0;
/*border: 2px solid red;*/
width: 60%;
height: 50%;
padding-bottom: 30px;
padding-top: 30px;
display: inline-flex;
flex-direction: row;
font-family: Helvetica;
color: white;
background: black;
opacity: 60%;
padding-left: 30px;
padding-right: 30px;
flex-direction: column;
top: 80px;
}
#myDIV2 {
position: fixed;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 100%;
text-align: center;
align-items: center;
justify-content: center;
padding: 1%;
/*background-color: lightblue;*/
flex-direction: row;
font-family: Helvetica;
display: none;
}
.myDIVbox2 {
position: relative;
left: 0;
/*border: 2px solid red;*/
width: 60%;
height: 50%;
padding-bottom: 30px;
padding-top: 30px;
display: inline-flex;
flex-direction: row;
font-family: Helvetica;
color: white;
background: black;
opacity: 60%;
padding-left: 30px;
padding-right: 30px;
flex-direction: column;
top: 80px;
}
<div class="LandingBar">
<button class="btn alignV" onclick="toggle1()">button 1</button>
<!--the buttons-->
<button class="btn-space alignV"></button>
<button class="btn alignV" onclick="toggle2()">button 2</button>
<button class="btn-space alignV"></button>
<button class="btn alignV" onclick="toggle()">the beatles</button>
</div>
<div id="myDIV">
<div class="myDIVbox">
<img class="logo" src="https://via.placeholder.com/300" height="20%" width="20%">
<br> Lorem Ipsum<br>
<br> Lorem Ipsum<br>
<br> lorem ipsum<br>
<button class="btn1">Lorem Ipsum</button>
</div>
</div>
<div id="myDIV2">
<div class="myDIVbox2">
content2<br> content
<br> content
<br>
<br>
<button class="btn1">Lorem Ipsum</button>
</div>
</div>
<div id="myDIV1">
<div class="myDIVbox1">
content1<br> content
<br> content
<br>
<br>
<button class="btn1">Lorem Ipsum</button>
</div>
</div>
Related
I have a popup window (within the same page) which I'm attempting to put a container which scrolls horizontally into, yet it distorts the popup window and does not display anything other than the scrollbar. I'm honestly at a loss, can anyone help me here? I've looked around for solutions but I can't find anything that I can see applies to my problem.
If anyone can help, or point me in the right direction, I'd be really grateful. The scrollbar works perfectly fine when isolated, but inside the window shows like this:
Standalone:
My HTML (popup window with scrollbar inside)
<div id="formula-popup" class="popup-window">
<div>
<a onclick="closeFormulaWindow()" title="Close" class="close">X</a>
<span id="ftitle" class="title1"></span>
<form method="post" id="formulaform" name="edit">
<span>Current Formula</span>
<p id="current-formula" class="formula">Existing formula</p>
<input id="id-passer" type="hidden" name="formula-id" value="">
<!--sort out horizontal scrollbar from bookmarks here later-->
<input onclick="refreshWindow()" name="edit-formula" type="submit" value="Confirm">
</form>
<div class="h-scrollbar">
<section class="h-scrollbar-container">
<div class="outer-wrapper">
<div class="inner-wrapper">
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
<div class="pseudo-item"></div>
</div>
</div>
<div class="pseudo-track"></div>
</section>
</div>
</div>
My CSS:
.scrollbar-container {
display: flex;
flex-direction: row;
}
.h-scrollbar {
display: flex;
max-width: 30vw;
padding: 0px 10px;
height: 20vh;
align-items: center;
justify-content: center;
overflow: hidden;
flex-shrink: 0;
}
.h-scrollbar-container {
width: 100%;
}
.outer-wrapper {
max-width: 100vw;
overflow-x: scroll;
position: relative;
scrollbar-color: #d5ac68 #f1db9d;
scrollbar-width: thin;
-ms-overflow-style: none;
}
.pseudo-track {
background-color: #f1db9d;
height: 2px;
width: 100%;
position: relative;
top: -3px;
z-index: -10;
}
.outer-wrapper::-webkit-scrollbar {
height: 5px;
}
.outer-wrapper::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 0px rgba(0, 0, 0, 0);
}
.outer-wrapper::-webkit-scrollbar-thumb {
height: 5px;
background-color: #d5ac68;
}
.outer-wrapper::-webkit-scrollbar-thumb:hover {
background-color: #f1db9d;
}
.outer-wrapper::-webkit-scrollbar:vertical {
display: none;
}
.inner-wrapper {
display: flex;
padding-bottom: 10px;
}
.pseudo-item {
height: 30px;
width: 80px;
margin-right: 15px;
flex-shrink: 0;
background-color: gray;
}
.pseudo-item:nth-of-type(2n) {
background-color: lightgray;
}
.popup-window {
position: fixed;
font-family: Arial, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: none;
}
.popup-window div {
width: 40vw;
height: 30vw;
position: relative;
margin: 10% auto 30%;
border-radius: 10px;
background: #213B54;
padding-top: 2vh;
padding-left: 1vw;
padding-right: 1vw;
padding-bottom: 2vh;
display: flex;
flex-direction: column;
}
.close {
font: Arial, sans-serif;
background: #067A9F;
color: #B5E5E7;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
border-radius: 12px;
box-shadow: 1px 1px 3px #000;
cursor: pointer;
}
.popup-window div .title1 {
font-family: Arial, sans-serif;
font-weight: normal;
font-size: 36px;
color: #EE6802;
align-self: center;
}
.popup-window form input[type=submit]:hover {
opacity: 0.8;
}
.popup-window form span {
color: #EE6802;
font-size: 22px;
}
.popup-window form {
display: flex;
flex-direction: column;
font-family: Arial, sans-serif;
}
.popup-window form span, input {
width: 100%;
}
.popup-window form input[type=submit] {
width: 20%;
background-color: #067A9F;
color: #213B54;
padding: 14px 0;
cursor: pointer;
border: none;
}
I found the solution, it was that I forgot to select an element inside the window properly and instead it was selecting all divs and so overriding the CSS properties.
I have a Text Messaging Mobile Site App that has the following divisions and CSS
.messageDisplay {
background-color: #ffffff;
position: absolute;
z-index: 99999;
height: 100%;
width: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow-y: hidden;
overflow-x: hidden;
visibility: hidden;
display: flex;
flex-direction: column;
justify-content: space-between;
transform: translateY(100%);
}
.messageDisplayHeader {
display: flex;
padding-top: 0.5em;
padding-bottom: 0.5em;
padding-left: 1em;
padding-right: 1em;
align-items: center;
background-color: #ffffff;
position: relative;
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}
.messageDisplayTextboxArea {
height: 3.5em;
position: relative;
box-shadow: rgb(0 0 0 / 16%) 0px -1px 4px;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding-left: 0.5em;
padding-right: 0.5em;
padding-top: 0.2em;
padding-bottom: 0.2em;
background-color: #000000;
}
.messageTextbox {
resize: none;
height: 2.5em;
width: calc(100% - 14%);
background-color: #fef3f1;
border: none;
border-radius: 100px;
padding-left: 1em;
padding-top: 0.5em;
padding-right: 1em;
color: #fc768a;
}
<div class="messageDisplay" id="messageDisplay">
<div class="messageDisplayHeader"></div>
<div class="messageDisplayBody" id="messageDisplayBody">
</div>
<div class="messageDisplayTextboxArea" id="messageDisplayTextboxArea">
<textarea id="messageTextbox" class="messageTextbox" maxlength="300" placeholder="Type a message"></textarea>
<div class="messageSendBtn" id="messageSendBtn">
<i data-feather="chevron-right"></i>
</div>
</div>
</div>
When using an IOS Device to focus in on the textarea the whole page shifts up.
When the textarea is focused out, the page stays shifted upwards.
I tried to solve this by doing the following:
var messageTextBoxEle = document.getElementById('messageTextbox');
messageTextBoxEle.onfocus = function(){
window.scrollTo(0, 0);
document.body.scrollTop = 0;
}
Right now it behaves as such
I also tried setting the page's margin-bottom:0; when the textarea is focused out but it doesnt seem to work.
Anyone have suggestions?
Please see code below:
.menu-notif-f {
position: absolute;
top: 50px;
right: 12px;
background-color: #ffffff;
width: 320px;
height: 480px;
overflow: hidden;
border-radius: 8px;
box-shadow: 0 3px 22px 0px rgb(0 0 0 / 15%);
animation: ani_desk_menuuserf .16s ease;
}
.menu-notif-t._title {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
color: #555555;
border-bottom: 1px solid #d5fff8;
}
.menu-notif-l._notif-title {
font-size: 16px;
font-weight: 600;
letter-spacing: .04px;
color: #555555;
}
.meni-notif-r._notif-see-all {
font-size: 14px;
font-weight: 500;
letter-spacing: .04px;
color: #01d2af;
}
._profile-c {
background: url(../media/icons/_overview/profile.png);
background-size: 66%;
}
.menu-notif-img {
width: 66px;
height: 66px;
/*height: 9vw;
max-width: 45px;
max-height: 45px;
min-width: 45px;
min-height: 45px;*/
background-color: #ffffff;
border-radius: 50px;
box-shadow: 0 1px 4px rgb(0 0 0 / 12%);
background-repeat: no-repeat;
background-position: center;
padding: 5px;
}
.menu-notif-c._notif-c {
display: flex;
justify-content: space-between;
align-items: center;
padding: 5px;
margin: 5px 5px;
}
.menu-notif-cl {
flex: 0 0 30%;
}
.menu-notif-cr {
flex: 0 0 70%;
}
.menu-notif-dt {
display: flex;
justify-content: space-between;
margin-bottom: 3px;
align-items: center;
}
.menu-notif-name {
font-size: 14px;
font-weight: 600;
color: #01d2af;
}
.menu-notif-time {
font-size: 13px;
font-weight: 600;
color: #657688;
}
.menu-notif-desc {
font-size: 13px;
color: #657688;
display: -webkit-box;
max-width: 100%;
/*height: 30px;*/
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.menu-notif-cc::-webkit-scrollbar {
display: none;
}
.menu-notif-cc {
overflow: auto;
height: 420px;
position: absolute;
left: 10px;
right: 10px;
bottom: 10px;
top: 50px;
}
.hdr-noah-c a {
color: #ffffff;
text-decoration: none;
}
<div class="menu-notif-f">
<div class="menu-notif-t _title">
<div class="menu-notif-l _notif-title">Notification</div>
<div class="meni-notif-r _notif-see-all">See All</div>
</div>
<div class="menu-notif-cc">
<div class="menu-notif-c _notif-c">
<div class="menu-notif-cl">
<div class="menu-notif-img _profile-c"></div>
</div>
<div class="menu-notif-cr">
<div class="menu-notif-dt">
<div class="menu-notif-name">Test Name</div>
<div class="menu-notif-time">03:53</div>
</div>
<div class="menu-notif-desc">
Login details need to be update
</div>
</div>
</div>
<div class="menu-notif-c _notif-c">
<div class="menu-notif-cl">
<div class="menu-notif-img _profile-c"></div>
</div>
<div class="menu-notif-cr">
<div class="menu-notif-dt">
<div class="menu-notif-name">Test Name</div>
<div class="menu-notif-time">03:53</div>
</div>
<div class="menu-notif-desc">
Login details need to be update
</div>
</div>
</div>
<!-- This will shown if there is no notification available. Hide if there is an exsiting notification. -->
<div class="message-notif">
<div class="currently-para">There's nothing to be shown as of now</div>
</div>
</div>
</div>
Can anyone help me with this? My goal is if there's a record the .message-notif class will hide and if there is no record The .message-notif class will show. using jQuery? Currently, I don't have any jQuery code that is why the .message-notif is showing, But now there 2 records so meaning the .message-notif should be hidden by now. Please help me with how can I accomplish that transition. Thanks in advance
Usually, for empty-list or things, there is how I manage it without JS : I never remove the item nor hide it. I just say that, if it's the last item in the list, I'll show it.
Let's say that you have a notice list in a div with class .notice-list. Put your 'empty' message in the notice list. Then :
.notice-list > .no-notice-to-show{
display: none;
}
.notice-list > >.no-notice-to-show:last-child{
display: block;
}
When you have a notice, just append your ntoice in the list. The notice will become the last child in your list, causing your 'empty' message to desapear.
Indeed, it doesn't work if you need your empty message to be displayed elsewhere tha tin the empty list. But it's rarely the case.
Used a for loop because you have no #id on the no message div tag, but something like this should work:
var notifications = document.querySelectorAll(".menu-notif-c");
var noNotif = document.querySelectorAll(".message-notif");
if (notifications.length > 0) {
for (let i = 0; i < noNotif.length; i++) {
noNotif[i].style.display = "block";
}
} else {
for (let i = 0; i < noNotif.length; i++) {
noNotif[i].style.display = "none";
}
}
If the <div class="menu-notif-c _notif-c"> wouldn't render if empty, I have a better solution for you.
Just use
.message-notif {display: none;}
.menu-notif-cc > .message-notif:nth-of-type(1) {
display: block;
}
This will hide and display the notification based on the presence of notification messages.
Full code snippet here:
.menu-notif-f {
position: absolute;
top: 50px;
right: 12px;
background-color: #ffffff;
width: 320px;
height: 480px;
overflow: hidden;
border-radius: 8px;
box-shadow: 0 3px 22px 0px rgb(0 0 0 / 15%);
animation: ani_desk_menuuserf .16s ease;
}
.menu-notif-t._title {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
color: #555555;
border-bottom: 1px solid #d5fff8;
}
.menu-notif-l._notif-title {
font-size: 16px;
font-weight: 600;
letter-spacing: .04px;
color: #555555;
}
.meni-notif-r._notif-see-all {
font-size: 14px;
font-weight: 500;
letter-spacing: .04px;
color: #01d2af;
}
._profile-c {
background: url(../media/icons/_overview/profile.png);
background-size: 66%;
}
.menu-notif-img {
width: 66px;
height: 66px;
/*height: 9vw;
max-width: 45px;
max-height: 45px;
min-width: 45px;
min-height: 45px;*/
background-color: #ffffff;
border-radius: 50px;
box-shadow: 0 1px 4px rgb(0 0 0 / 12%);
background-repeat: no-repeat;
background-position: center;
padding: 5px;
}
.menu-notif-c._notif-c {
display: flex;
justify-content: space-between;
align-items: center;
padding: 5px;
margin: 5px 5px;
}
.menu-notif-cl {
flex: 0 0 30%;
}
.menu-notif-cr {
flex: 0 0 70%;
}
.menu-notif-dt {
display: flex;
justify-content: space-between;
margin-bottom: 3px;
align-items: center;
}
.menu-notif-name {
font-size: 14px;
font-weight: 600;
color: #01d2af;
}
.menu-notif-time {
font-size: 13px;
font-weight: 600;
color: #657688;
}
.menu-notif-desc {
font-size: 13px;
color: #657688;
display: -webkit-box;
max-width: 100%;
/*height: 30px;*/
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.menu-notif-cc::-webkit-scrollbar {
display: none;
}
.menu-notif-cc {
overflow: auto;
height: 420px;
position: absolute;
left: 10px;
right: 10px;
bottom: 10px;
top: 50px;
}
.hdr-noah-c a {
color: #ffffff;
text-decoration: none;
}
.message-notif {display: none;}
.menu-notif-cc > .message-notif:nth-of-type(1) {
display: block;
}
<div class="menu-notif-f">
<div class="menu-notif-t _title">
<div class="menu-notif-l _notif-title">Notification</div>
<div class="meni-notif-r _notif-see-all">See All</div>
</div>
<div class="menu-notif-cc">
<div class="menu-notif-c _notif-c">
<div class="menu-notif-cl">
<div class="menu-notif-img _profile-c"></div>
</div>
<div class="menu-notif-cr">
<div class="menu-notif-dt">
<div class="menu-notif-name">Test Name</div>
<div class="menu-notif-time">03:53</div>
</div>
<div class="menu-notif-desc">
Login details need to be update
</div>
</div>
</div>
<div class="menu-notif-c _notif-c">
<div class="menu-notif-cl">
<div class="menu-notif-img _profile-c"></div>
</div>
<div class="menu-notif-cr">
<div class="menu-notif-dt">
<div class="menu-notif-name">Test Name</div>
<div class="menu-notif-time">03:53</div>
</div>
<div class="menu-notif-desc">
Login details need to be update
</div>
</div>
</div>
<!-- This will shown if there is no notification available. Hide if there is an exsiting notification. -->
<div class="message-notif">
<div class="currently-para">There's nothing to be shown as of now</div>
</div>
</div>
</div>
Same code without the <div class="menu-notif-c _notif-c"> inside the parent <div class="menu-notif-cc">
.menu-notif-f {
position: absolute;
top: 50px;
right: 12px;
background-color: #ffffff;
width: 320px;
height: 480px;
overflow: hidden;
border-radius: 8px;
box-shadow: 0 3px 22px 0px rgb(0 0 0 / 15%);
animation: ani_desk_menuuserf .16s ease;
}
.menu-notif-t._title {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
color: #555555;
border-bottom: 1px solid #d5fff8;
}
.menu-notif-l._notif-title {
font-size: 16px;
font-weight: 600;
letter-spacing: .04px;
color: #555555;
}
.meni-notif-r._notif-see-all {
font-size: 14px;
font-weight: 500;
letter-spacing: .04px;
color: #01d2af;
}
._profile-c {
background: url(../media/icons/_overview/profile.png);
background-size: 66%;
}
.menu-notif-img {
width: 66px;
height: 66px;
/*height: 9vw;
max-width: 45px;
max-height: 45px;
min-width: 45px;
min-height: 45px;*/
background-color: #ffffff;
border-radius: 50px;
box-shadow: 0 1px 4px rgb(0 0 0 / 12%);
background-repeat: no-repeat;
background-position: center;
padding: 5px;
}
.menu-notif-c._notif-c {
display: flex;
justify-content: space-between;
align-items: center;
padding: 5px;
margin: 5px 5px;
}
.menu-notif-cl {
flex: 0 0 30%;
}
.menu-notif-cr {
flex: 0 0 70%;
}
.menu-notif-dt {
display: flex;
justify-content: space-between;
margin-bottom: 3px;
align-items: center;
}
.menu-notif-name {
font-size: 14px;
font-weight: 600;
color: #01d2af;
}
.menu-notif-time {
font-size: 13px;
font-weight: 600;
color: #657688;
}
.menu-notif-desc {
font-size: 13px;
color: #657688;
display: -webkit-box;
max-width: 100%;
/*height: 30px;*/
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.menu-notif-cc::-webkit-scrollbar {
display: none;
}
.menu-notif-cc {
overflow: auto;
height: 420px;
position: absolute;
left: 10px;
right: 10px;
bottom: 10px;
top: 50px;
}
.hdr-noah-c a {
color: #ffffff;
text-decoration: none;
}
.message-notif {display: none;}
.menu-notif-cc > .message-notif:nth-of-type(1) {
display: block;
}
<div class="menu-notif-f">
<div class="menu-notif-t _title">
<div class="menu-notif-l _notif-title">Notification</div>
<div class="meni-notif-r _notif-see-all">See All</div>
</div>
<div class="menu-notif-cc">
<!-- This will shown if there is no notification available. Hide if there is an exsiting notification. -->
<div class="message-notif">
<div class="currently-para">There's nothing to be shown as of now</div>
</div>
</div>
</div>
I have been trying to get this layout to animate the search box when clicking on the search icon. It kind of works, except for two things. When the animation begins, the search icon quickly moves to the left where I'd like it to stay put and the search box extend out to the left. That would then push the logo over at the same time the logo switches to the small version.
Any guidance would be appreciated. Here is a JSFIDDLE and the code:
HTML:
<button class="hamburger hamburger-cancel" id="menu-trigger">
<span class="icon"></span>
</button>
<a id="site-logo" data-cy="site-logo" href="http://www.website.local">
<img class="full-logo" src="https://www.tracetronic.com/cms/data/img/inhalte/Logos_TraceTronic/Logo_TEST-GUIDE_rgb_SCREEN.jpg" alt="Engineering360 Logo">
<img class="logo-kite" src="http://i.imgur.com/w4MxJnp.png" alt="Engineering360 Logo Kite">
</a>
<form id="global-search-form" action="/search" data-cy="global-search-form">
<input class="search-box catcomplete" type="text" name="query" required="" value="" data-cy="global-search-box">
<input type="hidden" name="newSearch" value="new">
<input class="submit" type="submit" value="">
</form>
<div class="header-reg-links">
<img id="reg-trigger" data-cy="profile-popup-trigger" src="https://www.freeiconspng.com/uploads/profile-icon-9.png">
</div>
</div>
</header>
CSS/SCSS:
header {
background: black;
background-size: cover;
box-sizing: border-box;
padding: 0 .5em;
position: relative;
width: 100%;
z-index: 10;
#header-content {
align-items: center;
display: flex;
flex-flow: row nowrap;
margin: 0 auto;
max-width: 1140px;
#site-logo {
margin: .5em 2em;
min-width: 0;
flex-grow: 1;
text-align: center;
.logo-kite {
display: none;
}
img {
height: auto;
width: 5em;
}
}
.header-reg-links {
align-items: center;
display: flex;
position: relative;
#reg-trigger {
cursor: pointer;
margin-left: auto;
min-width: 0;
transition: opacity .3s;
width: 2.25em;
height: 1.75em;
padding: 1em .25em;
&:hover {
opacity: 0.9;
}
}
}
#global-search-form {
align-items: center;
display: flex;
flex-flow: row nowrap;
flex-grow: 0;
font-size: 15px;
min-width: 0;
padding: 0 2em;
margin: .5em 0;
padding: 0 .5em;
.nav-search-dropdown {
display: none;
}
.search-box {
background: #fbfbfb;
box-sizing: border-box;
border: 0;
font-size: 15px;
height: 2.25em;
line-height: 2.25em;
margin: 0;
min-width: 0;
flex: 0;
max-width: 40em;
overflow: hidden;
text-overflow: ellipsis;
padding: 0;
transition: width 1s;
width: 0;
}
.submit {
border: 0;
border-radius: 0 3px 3px 0;
box-sizing: border-box;
cursor: pointer;
height: 2.25em;
font-size: 15px;
min-width: 0;
background: url("https://vignette.wikia.nocookie.net/deusex/images/9/9b/Magnifying_glass_icon.png/revision/latest?cb=20141205155051&path-prefix=en") center center / 1.65em no-repeat;
padding: 0;
width: 2em;
}
}
&.search-open {
#site-logo {
flex: 0 0 2em;
margin: 0 .5em;
.logo-kite {
display: block;
width: 2em;
}
.full-logo {
display: none;
}
}
#global-search-form {
flex: 1 1 0;
margin: 0;
padding: 0;
width: 16em;
.search-box {
flex: none;
padding: .25em .5em;
width: 90%;
}
.search-trigger {
display: none;
}
}
}
}
#menu-trigger {
background: transparent;
border: 0 none;
cursor: pointer;
display: inline-block;
height: 1em;
outline: none;
padding: 0;
transition: transform .2s ease-in-out;
vertical-align: middle;
flex: 0 0 1.25em;
font-size: 1.5rem;
margin: 0 .25em;
width: 1.5em;
&:before, &:after {
content: "";
}
&:before, &:after, .icon {
background: #FBFBFB;
border-radius: .05em;
display: block;
height: .1em;
margin: 0 0 .3em;
transition: transform .2s ease-in-out;
width: 100%;
}
&.menu-open:before {
transform: translateY(.4em) rotate(135deg);
}
&.menu-open .icon {
transform: scale(0);
}
&.menu-open:after {
transform: translateY(-.4em) rotate(-135deg);
}
}
}
JQUERY:
$(function() {
// Click event for profile icon.
$("#reg-trigger").click(function() {
$("#header-content .header-reg-links").toggleClass("active");
$(document).on("click.document", function(e) {
var container = $("#header-content .header-reg-links");
// if the target of the click isn't the container nor a descendant of the container
if (!container.is(e.target) && container.has(e.target).length === 0) {
container.removeClass("active");
// remove the click event on the document when it's no longer needed.
$(document).off("click.document");
}
});
})
// Opens main menu
$("#menu-trigger").click(function() {
$("html, #menu-trigger, #site-nav").toggleClass("menu-open");
});
// Header search bar toggle
$("#global-search-form input.submit").click(function(e) {
console.log($("#global-search-form input.search-box").val());
if ($("#header-content").hasClass("search-open")) {
if ($("#global-search-form input.search-box").val() == "") {
e.preventDefault();
$("#header-content").toggleClass("search-open");
} else {
return true;
}
} else {
e.preventDefault();
$("#header-content").toggleClass("search-open");
}
});
});
On the bottom of my page I a using a scroll to top button with a Font Awesome icon. The up arrow has a background color with border: 50% and a hover color. Ive searched all over and border 50% should make a circle shape but something is preventing it in this case. I want a simple circle background color over the icon.
my code
#Scroll {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
border: none;
outline: none;
background-color: #5F9EA0;
color: white;
text-align:center;
cursor: pointer;
padding: 15x;
border-radius: 50%;
opacity: .6;
}
#Scroll:hover {
color: #004289;
background-color: #FFE466;
}
<button onclick="topFunction()" id="Scroll" title="Go to top"><i class="fa fa-2x fa-arrow-circle-up"></i></button>
<script>
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("Scroll").style.display = "block";
} else {
document.getElementById("Scroll").style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>
Make the button square:
#Scroll {
height: 40px;
width: 40px;
}
Try this css for the button:
#Scroll {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
border: none;
outline: none;
background-color: #5F9EA0;
color: white;
text-align: center;
cursor: pointer;
opacity: .6;
/* add this */
width: 50px;
height: 50px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
}