CSS3 fold and unfold effect - html

I need a little bit of help.
I am using the following html and css in CodePen. Basically I need it to start in a folded state rather than open.
I need the folder cover (top div) to always be unfolded as this will show information on how to open the content as the cover needs to contain a fold/unfold link. Also when I enter content in to each of the fold divs the content runs over to the next div, rather than expanding the current div as you will see in my edited CodePen below.
This would also need to be resolved so that it does not cause an issue when it is folded as the divs become misaligned.
Original CodePen
http://codepen.io/boxabrain/pen/Hhugb/
My edited CodePen
http://codepen.io/anon/pen/gmAnK
HTML
<div id="folder">
<input type="checkbox" id="toggle"/> <label for="toggle" id="toggle- label">fold/unfold</label>
<div class="fold">
Element 1
</div>
<div class="fold">
Element 2
</div>
<div class="fold">
Element 3
</div>
<div class="fold">
Element 4
</div>
<div class="fold">
Element 5
</div>
<div class="fold">
Element 6
</div>
<div class="fold">
Element 7
</div>
<div class="fold">
Element 8
</div>
</div>
CSS
body {
padding: 50px;
font-family: Arial, sans-serif;
}
#folder {
width: 300px;
padding: 10px;
}
.fold {
background: #000;
background: #000;
padding: 10px;
width: 280px;
height: 80px;
color: #999;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s linear;
transition: all 0.3s linear;
}
#toggle { display: none; }
#toggle-label {
display: inline-block;
cursor: pointer;
margin-bottom: 50px;
border: 1px solid #e5e5e5;
font-size: 11px;
color: #999;
background: #fff;
text-transform: uppercase;
border-radius: 5px;
padding: 5px;
}
#toggle:checked ~ .fold:nth-child(odd) {
margin-top: -82px;
-webkit-transform: perspective(800px) rotateX(-80deg);
-moz-transform: perspective(800px) rotateX(-80deg);
transform: perspective(800px) rotateX(-80deg);
}
#toggle:checked ~ .fold:nth-child(even) {
margin-top: -84px;
-webkit-transform: perspective(800px) rotateX(80deg);
-moz-transform: perspective(800px) rotateX(80deg);
transform: perspective(800px) rotateX(80deg);
}
Can anyone help me?
Thanks in advance

To start out in a folded state, just add :not selector like this:
#toggle:not(:checked) ~ .fold:nth-child(odd)
#toggle:not(:checked) ~ .fold:nth-child(even)
About content overflow - you need to adjust it by hands if you don't want to use Js (play with individual .folds heights and rotateX).

Related

how to adjust size of 'tick' inside checkbox?

I have given an input element type checkbox, its fine but when its checked tick seems very big.
I need to make smaller that tick symbol
here is html content from browser:
<div class="defaultRoot">
<div class="defaultBody ">
<div class="checkboxWrapper">
<input id="kis-9l7v7o3vr" type="checkbox" class="kischeckbox" style="width: 24px; height: 24px; accent-color: rgb(47, 55, 93); border: 4px solid gray; border-radius: 0px; display: block; transition: border-color 0ms ease 0s, background-color 0ms ease 0s; cursor: default;">
</div>
<div class="labelWrapper">
<label class="label" data-disabled="false" for="kis-9l7v7o3vr">I agree to sell my privacy</label>
</div>
</div>
</div>
How can I make that tick smaller and thinner
Currently the browser does not (and will not) support virtual elements to the tick of the checkbox you have to customize them yourself. refer here: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_checkbox
using CSS you can adjust the size of the tick inside the checkbox as follow
<!DOCTYPE html>
<html>
<head>
<title>Adjust Checkbox Tick Size</title>
<style>
.checkboxWrapper, .labelWrapper {
display: inline-block;
vertical-align: middle;
}
input[type=checkbox].kischeckbox {
display: inline-block;
width: 14px;
height: 14px;
accent-color: rgb(47, 55, 93);
border: 4px solid gray;
border-radius: 0px;
display: block;
transition: border-color 0ms ease 0s;
cursor: default;
vertical-align: middle;
}
input[type=checkbox].kischeckbox:checked + label::before {
content: "\2714"; /* tick symbol */
font-size: 16px; /* adjust the size of the tick here */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="defaultRoot">
<div class="defaultBody ">
<div class="checkboxWrapper">
<input id="kis-9l7v7o3vr" type="checkbox" class="kischeckbox">
</div>
<div class="labelWrapper">
<label class="label" data-disabled="false" for="kis-9l7v7o3vr">I agree to sell my privacy</label>
</div>
</div>
</div>
</body>
</html>

My navigation buttons in HTML website renders in Chrome and Firefox but not Safari?

Here I have the issue where my navigation bar for my website renders in Chrome and Firefox, but in Safari, it does not render at all. The clicks still work, but I cannot see the buttons visually.
See this picture:
Firefox is on the left and Safari is on the right.
Here is the HTML code for the navigation bar:
<nav class="topbar">
<div class="nav_graphics">
<a href="https://play.google.com/store/apps/dev?id=4853083882678511028" target="_blank">
<img class="toxic_flame_icon" src="/images/toxicflame427_icon.png" alt="ToxicFlame427 Icon"/>
</a>
<h1 class="title_header">ToxicFlame427</h1>
</div>
<div class="nav_buttons">
<!--Link the different pages to the main site-->
<a href="/index.html">
<button>
<h3>Home</h3>
</button>
</a>
<a href="/pages/my_creations.html">
<button>
<h3>My Creations</h3>
</button>
</a>
<a href="/pages/about.html">
<button>
<h3>About</h3>
</button>
</a>
<a href="/pages/bug_report.html" class="report_bug_button">
<button>
<h3>Report A Bug</h3>
</button>
</a>
</div>
</nav>
And here is the CSS for it too:
#font-face {
font-family: "ArcadeClassic";
src: url("/font/ArcadeClassic.woff");
}
.topbar{
padding: 10px;
align-content: flex-start;
width: 100%;
height: wrap;
background-color: black;
}
.nav_graphics{
display: flex;
}
.nav_buttons{
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.title_header{
font-family: "ArcadeClassic";
font-size: 2.0em;
vertical-align: top;
display: inline-block;
color: teal;
margin-left: 20px;
margin-right: 20px;
}
.toxic_flame_icon{
display: inline-block;
height: 100px;
transition: 1s;
}
.toxic_flame_icon:hover{
transform: rotate(180deg);
}
.topbar button{
font-size: 0.9em;
transition: 0.25s;
-webkit-transition: 0.25s;
-moz-transition: 0.25s;
-o-transition: 0.25s;
position: relative;
bottom: 15px;
border-radius: 5px;
border-color: transparent;
color: red;
height: 15%;
width: 130px;
background-color: transparent;
font-weight: bold;
margin-top: 15px;
}
#media only screen and (max-width:600px){
.topbar button{
font-size: 0.8em;
}
.title_header{
font-size: 1.7em;
}
}
.topbar button:hover{
color: turquoise;
transform: translateY(-5px);
-webkit-transform: translateY(-5px);
-o-transform: translateY(-5px);
-ms-transform: translateY(-5px);
-moz-transform: translateY(-5px);
}
/*Make sure that the little blue lines cant be seen*/
.topbar a{
color: transparent;
}
May it have something to do with font? Or something else i did not catch?
The site is online at https://toxicflame427.xyz if anyone needs to see more code.
It's happening because your button element has 15% height and the way Safari and other browsers handle the overflow inside a button is different.
Simply remove the height restriction (or set it larger) and it will work.
Also, side note: in both browsers, the button is not covering its content and it's not a good practice. Plus, a percentage height inside an a element without a specified height is not good either.

Hover effecting other elements other than the item being hovered

I am having a hover issue. Whenever I hover over a specific .servNavItemTitle the font weight for the other .servNavItemTitle decreases for a moment and then goes back to normal quickly.
To see it in the demo, just hover over one of the titles and watch the other titles as the font-weight reduces.
Does anyone see what the issue is?
Here is a jsfiddle demo
Here is a narrowed down version of the code:
.servNavItemWrap {
display: inline-block;
vertical-align: top;
width: 25%;
margin-bottom: 50px;
text-align: center;
cursor: pointer;
}
.servNavItemWrap img {
width: 75px;
height: 75px;
-webkit-transition: all 0.25s;
transition: all 0.25s;
}
.servNavItemWrap:hover img {
-webkit-transition: all 0.25s;
transition: all 0.25s;
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
.servNavItemWrap a {
text-decoration: none;
outline: none;
}
.servNavItemTitle {
margin-top: 5px;
-webkit-transition: all 0.25s;
transition: all 0.25s;
}
.servNavItemWrap:hover .servNavItemTitle {
color: #FFF;
-webkit-transition: all 0.25s;
transition: all 0.25s;
}
<div id="serviceNavBlock2" class="iblock">
<div class="servNavItemWrap">
<a href="http://localhost:8080/profile.php">
<img src="" alt="Aluminum Profile">
<span class="servNavItemTitle hGc block">Aluminum</span>
</a>
</div>
<div class="servNavItemWrap">
<a href="#">
<img src="" alt="Aluminum Components">
<span class="servNavItemTitle hGc block">Components</span>
</a>
</div>
After Temani narrowed down the issue, I searched and found the answer here: css transform element affects other element which use transform:scale(0.5) in android webview . Basically, I added -webkit-backface-visibility: hidden; to the scaled image and it works perfectly now.

How to make a pure CSS bootstrap onclick and hover dropdown menu?

There is a pure CSS (no JavaScript) dropdown menu activated on hover, and the menu stays open if you click it.
It's here: Making Animated Dropdown Menu by Using Pure CSS Like Bootstrap does
Here's the code:
html, body {
margin:0;
}
.acn-menu {
text-align: center;
background-color: rgba(0, 0, 0, 0.9);
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
min-height: 74px;
width: 100%;
}
.label_openclose {
display: none;
}
.menu-tabs {
height: 100%;
}
.menu-tabs .elem {
box-sizing: border-box;
padding: 0 20px;
float: left;
height: 100%;
line-height: 70px;
background-color: rgb(30, 30, 30);
color: white;
}
#-webkit-keyframes spin {
0% {
transform: rotate(-180deg);
}
50% {
transform: rotate(180deg);
}
100% {
transform: rotate(-180deg);
}
}
#keyframes spin {
0% {
transform: rotate(-180deg);
}
50% {
transform: rotate(180deg);
}
100% {
transform: rotate(-180deg);
}
}
.menu-check:checked ~ .label_openclose {
-webkit-animation-play-state: paused;
animation-play-state: paused;
}
.menu-check {
display: none;
}
.menu-tabs .elem:hover {
background-color: rgba(255, 255, 255, 0.2);
}
/*#media screen and (max-width:55%)*/
#media screen and (max-width:768px) {
.label_openclose {
-webkit-animation: spin 2s;
animation: spin 2s;
display: inline-block;
transform: rotate(-180deg);
transition-duration: 1s;
margin: 10px;
width: 30px;
height: 30px;
border-radius: 50%;
border-top: 10px solid rgb(50, 50, 50);
border-right: 10px solid rgb(100, 100, 100);
border-bottom: 10px solid rgb(150, 150, 150);
border-left: 10px solid rgb(200, 200, 200);
background-color: transparent;
cursor: pointer;
}
.label_openclose:hover {
transform: rotate(180deg);
}
.menu-tabs .elem {
transition: border 1s linear, height 1s;
line-height: initial;
float: initial;
height: 0px;
cursor: pointer;
border-top: 0px solid #000;
overflow: hidden;
}
.menu-tabs:hover .elem {
height: 25px;
}
.menu-check:checked ~ .menu-tabs .elem {
height: 25px;
color: white;
border-top: 2px solid rgba(255, 255, 255, 0.2);
}
.label_openclose:hover ~ .menu-tabs .elem {
border-top: 2px solid rgba(255, 255, 255, 0.2);
height: 25px;
}
}
<div class="acn-menu">
<input type="checkbox" id="openclose" class="menu-check" />
<label class="label_openclose" for="openclose"></label>
<div class="menu-tabs">
<div class="elem">test</div>
<div class="elem">nav</div>
<div class="elem">bar</div>
<div class="elem">with</div>
<div class="elem">transitions</div>
</div>
</div>
<main>
test content of main page</br>The navbar menu stays open when you click on the circle</br>and it even opens on hover, not just on click.
</main>
I would put the drop down where it says "Solutions" in the navbar:
How could I make this work with the default bootstrap 3 navbar menu?
The trick is in the :checked and :hover CSS psuedo-class selectors on a checkbox in combination with ~ (the general sibling combinator). The combinator (~) sounds complicated, but it basically just means select any sibling after the ~ if it is present in html after the selector before the ~. For example:
.before ~ .after {
background-color: orange;
}
...
<div>
<p class = "before">Before</p>
<p class = "after">After</p> <!-- I'll be orange -->
<p class = "after">After</p> <!-- Me too! -->
<p class = "after">After</p> <!-- You get the point -->
</div>
So basically all you need is (1) a checkbox element (2) a label for said checkbox, and (3) a menu (with as many children as you want). And all three have to be siblings so that checking / unchecking the checkbox can toggle the classes of the other two elements via the psuedo-class selectors and the ~ combinator.
In the example you showed, the checkbox display is set to none, but that's just because its ugly. It could easily still be there and the menu toggle would function the same. You can toggle the check with the label alone, so it's doesn't really matter. But the invisible checkbox is what makes everything happen. You could style it directly and forget the label if you wanted to.
So all you need to do is set the menu to hidden, and the menu after the ~ combinator to show if the checkbox is either checked or hovered over:
.menu {
display: none;
}
.check-toggle:checked ~ .menu, .check-toggle:hover ~ .menu {
display: block;
}
...
<input id="checkBox" class="check-toggle" type="checkbox"/>
<label for="checkBox">MENU</label>
<div class="menu">
<div>Menu Items</div>
<div>Menu Items</div>
<div>Menu Items</div>
<div>Menu Items</div>
</div>
It might be an absolute pain to find a perfect replica of this in bootstrap, or it might be easy, I'm not sure. But you don't really need it. You can just add the invisible checkbox, the label, and the menu with the toggling selectors, and then style everything else with bootstrap.You might need to over-power the cascade, but worst comes to worst you can make special toggling selectors with an id instead of a class.
Here is a minimalist working example:
<style>
.check-toggle {
/*display: none;*/
}
.menu {
display: none;
position: absolute;
background-color: white;
border: 2px solid black;
margin-top: -2px;
}
.menu:hover {
display: block;
}
.check-toggle:checked ~ label, .check-toggle:hover ~ label {
color: orange;
}
.check-toggle:checked ~ .menu, .check-toggle:hover ~ .menu {
display: block;
}
</style>
<div>
<input id="checkBox" class="check-toggle" type="checkbox"/>
<label for="checkBox">MENU</label>
<div class="menu">
<div>Menu Items</div>
<div>Menu Items</div>
<div>Menu Items</div>
<div>Menu Items</div>
</div>
</div>
You can use :focus for this. Check out the example code.
Drawback: You cannot toggle the dropdown (You can open it but cannot close it).

Decreasing opacity on hover

I have three divs in a tag.
<nav>
<div id="home">
<p>Home</p>
</div>
<div id="about">
<p>About Me</p>
</div>
<div id="contact">
<p>Contact</p>
</div>
</nav>
I want to make 3 buttons which changes its opacity to 1 when hovered, but i end up unsuccessful. Firstly, I declared nav's opacity as 0.3, and then set it's opacity to 1 when hovered. But it stays as 0.3 when hovered. I thought :hover pseudo-selectors are more specisic, so they would overwrite the old value, but they didnt. Here is the CSS code:
#home, #about, #contact {
text-align: center;
color: #eedd33;
display: inherit;
padding-top: 0px;
font-family: Tahoma;
border-right: solid 1px black;
height: 50px;
vertical-align: middle;
padding: 10px;
}
#home:hover, #about:hover, #contact:hover {
opacity: 1;
}
nav {
border: solid 2px black;
display: inline-block;
background: orange;
border-radius: 7px;
opacity: 0.3;
}
I can post images indicating my problem if you want it.
The nav's opacity is inherited by the children. Even if their's is 1 they will only show 0.3 opacity. Define the opacity of the children to be 0.3 instead.
Just create a generic class for each of the inner divs or change the CSS selector to something like this:
nav > #home:hover,
nav > #about:hover,
nav > #contact:hover {
opacity: 1;
}
Heres the JSFiddle http://jsfiddle.net/rZgzL/