I'm playing around with a pure CSS accordion http://reversl.net/accordion/ I can get the basic functionality to work (headings 2 & 3 both toggle) But I can't get heading 1 to toggle if I add the same UL to it. Because Heading 1 is styled differently the problem (I think) lies within naming/targeting it's + div ?
Please note: I removed the UL from Heading 1 for the sake of the demo because it was preventing Headings 2 & 3 from toggling.
You made several mistakes. Too many to count:
Here is a working example: Try and see, what I changed
http://jsfiddle.net/HerrSerker/ASqE9/
HTML
<div id="wrap">
<div class="accordion">
<div id="two" class="section">
<h4>
Heading 2
</h4>
<div class="sub_section">
<ul class="list">
<li>Sample Text 1</li>
<li class="last">Sample Text 2</li>
</ul>
</div>
</div><!--#two-->
<div id="four" class="section progress">
<h4>
Heading 4 (With Progress Bar)
</h4>
<div class="metrics">
<div class="meter">
<span style="width: 75%"></span>
</div><!--.meter-->
</div><!--.metrics-->
<div class="sub_section">
<ul class="list">
<li>Sample Text 1</li>
<li class="last">Sample Text 2</li>
</ul>
</div><!--.sub_section-->
</div><!--#one-->
</div><!--accordian-->
</div>
CSS
#wrap {
width: 320px;
background: #f0f0f0;
margin: auto;
}
.accordion {
clear: both;
padding: 0;
margin: 0 auto;
}
.accordion h4 {
margin: 0;
}
.accordion h4 a {
padding: 1em;
color: #999;
display: block;
font-weight: normal;
text-decoration: none;
}
.accordion h4 a:hover {
text-decoration: none;
background: #111;
}
.accordion .section {
background: #222;
border-bottom: 1px solid #000;
}
.accordion .sub_section {
border-bottom: none;
background: #f0f0f0;
}
.list {
padding: 0;
margin: 0;
}
.list li {
background: url('http://www.placehold.it/40x40') no-repeat;
color: #999;
list-style: none;
padding: .7em .7em .7em 4em;
border-bottom: 1px solid #fff;
}
.list .last {
border-bottom: none;
}
.accordion .sub_section {
height: 0;
overflow: hidden;
-webkit-transition: height 0.3s ease-in;
-moz-transition: height 0.3s ease-in;
-o-transition: height 0.3s ease-in;
-ms-transition: height 0.3s ease-in;
transition: height 0.3s ease-in;
}
.accordion :target h4 a {
text-decoration: none;
font-weight: bold;
}
.accordion :target .sub_section {
height: 80px;
}
.accordion .section.large:target h4 + div {
overflow: auto;
}
.accordion p {
color: #646464;
}
.accordion .progress .meter {
width: 90%;
height: 2px;
position: relative;
background: #555;
margin: -.9em auto .5em auto;
padding: 1px;
}
.meter > span {
height: 2px;
display: block;
background-color: #f0f0f0;
position: relative;
overflow: hidden;
}
This is because the class "progress" assigned to the div id="one" that keeps constant the size of the div with the content.
Related
is it possible not to trigger the animation indefinitely when you move the cursor at the bottom of the button?
here's how it looks like -- gif and codepen
.container {
padding: 1rem;
}
.container .here {
text-decoration: none;
color: white;
background: darkgreen;
display: inline-block;
margin: 2rem;
padding: 1rem;
transition: all .1s;
}
.container .here:hover {
transform: translateY(-1.5rem) scale(1.5);
}
<div class="container">
<div class="here">hover here</div>
</div>
Make the button bigger at the bottom by adding a pseudo element and you will avoid the flicker:
.container {
padding: 1rem;
}
.container .here {
text-decoration: none;
color: white;
background: darkgreen;
display: inline-block;
margin: 2rem;
padding: 1rem;
transition: all .1s;
position:relative;
}
.container .here:before {
content:"";
position:absolute;
top:100%;
left:0;
right:0;
}
.container .here:hover {
transform: translateY(-1.5rem) scale(1.5);
}
.container .here:hover:before {
height:1.5rem;
}
<div class="container">
<div class="here">hover here</div>
</div>
I want to do a collapsible button that opens a list of items when clicked, I'm trying to float the elements left within the button but it's not seem to be working.
.collapsible-group {
overflow: hidden;
}
.collapsible-content {
float: left;
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
display: block;
}
.collapsible {
color: black;
cursor: pointer;
padding: 18px;
width: 33%;
border: none;
text-align: center;
outline: none;
font-size: 15px;
background-color: Transparent;
display: block;
margin: auto;
}
<div class="collapsible-group">
<button class="collapsible">Modern Trade</button>
<div class="collapsible-content">
<ul>
<li>num 1</li>
<li>num2</li>
<li>num3</li>
<li>num4</li>
</ul>
</div>
</div>
Please try the following
<div class="collapsible-content">
<ul class=my-float"> <li>num 1</li>
<li>num2</li>
<li>num3</li>
<li>num4</li></ul>
// in your css file add this
.my-float li{
float:left;
}
You need Javascript to detect the button click and then do something with it. This code adds a class to the div containing the menu and changes the maximum height.
const myButton = document.getElementsByTagName("button")[0];
myButton.onclick = () => {
const menu = document.getElementsByClassName("collapsible-content")[0];
menu.classList.toggle("showMenu");
}
.collapsible-group {
overflow: hidden;
}
.collapsible-content {
float: left;
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
display: block;
}
.collapsible-content.showMenu {
max-height: 1000px;
}
.collapsible {
color: black;
cursor: pointer;
padding: 18px;
width: 33%;
border: none;
text-align: center;
outline: none;
font-size: 15px;
background-color: Transparent;
display: block;
margin: auto;
}
<div class="collapsible-group">
<button class="collapsible">Modern Trade</button>
<div class="collapsible-content">
<ul>
<li>num 1</li>
<li>num 2</li>
<li>num 3</li>
<li>num 4</li>
</ul>
</div>
</div>
How can I get this navigation bar to center?
The class menu I suppose is built in with bootstrap.min.css.
#header {
position: fixed;
width: 100%;
z-index: 999;
}
#header .header-content {
margin: 0px auto;
max-width: 1170px;
padding: 60px 0;
width: 100%;
-moz-transition: padding 0.4s;
-o-transition: padding 0.4s;
-webkit-transition: padding 0.4s;
transition: padding 0.4s;
}
.navigation {
float: right;
}
.navigation li {
display: inline-block;
}
.navigation a {
color: white;
font-size: 15px;
font-weight: bold; /* Normal - Bold - 400 */
margin-left: 30px;
letter-spacing: 4px;
text-transform: uppercase;
}
.navigation a:hover, .navigation a.active {
color: white;
}
<header id="header">
<div class="menu">
<div class="header-content clearfix">
<nav class="navigation" role="navigation">
<ul>
<li><a data-scroll href="#sec1">Inicio</a></li>
<li><a data-scroll href="#sec2">UEFA</a></li>
<li><a data-scroll href="#sec4">Equipo</a></li>
<li><a data-scroll href="#sec3">Contacto</a></li>
</ul>
</nav>
Menu<span></span>
</div>
</div>
</header>
If you remove the float: right from .navigation and you set text-align: center to that div you can center it.
https://codepen.io/anon/pen/BmBPej
I was building a portfolio website purely out of html5 and css and I am stuck at sticking the footer at the bottom of the page.
Here are the codes:
contact.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>contact | sadman s.</title>
<link type="text/css" rel="stylesheet" href="stylesheet.css">
<link href='http://fonts.googleapis.com/css?family=Droid+Serif' rel='stylesheet' type='text/css'>
</head>
<body>
<header>
<h1>sadman s.</h1>
</header>
<!--NAVIGATION BAR-->
<nav>
<ul>
<li>h o m e</li>
<li>b l o g</li>
<li>p o r t f o l i o</li>
<li>a b o u t</li>
<li>c o n t a c t</li>
</ul>
</nav>
<!--NAVIGATION BAR ENDS-->
<!--BODY STARTS HERE-->
<body>
<form>
<label>Name</label>
<input name="name" placeholder="Name">
<label>Email</label>
<input name="email" type="email" placeholder="Email">
<label>Message</label>
<textarea name="message" placeholder="Your message"></textarea>
<input id="submit" name="submit" type="submit" value="SEND">
</form>
</body>
<!--BODY ENDS HERE-->
<!--FOOTER STARTS HERE-->
<footer>
<div id="footer_line"></div>
<!--FOOTER LINKS BAR-->
<nav>
<ul>
<li><span id="footer_bar">t w i t t e r</span></li>
<li><span id="footer_bar">i n s t a g r a m</span></li>
<li><span id="footer_bar">g i t h u b</span></li>
</ul>
</nav>
<!--FOOTER BAR ENDS-->
<p>copyright © 2014 - <span id="footer_link">sadman.de</span>. all rights reserved.</p>
</footer>
</html>
stylesheet.css
* {
margin: 0;
padding: 0;
font-family: Droid Serif;
}
body {
font-family: Droid Serif;
}
header {
font-family: Droid Serif;
font-weight: lighter;
font-size: 1.8em;
text-align: center;
text-transform: uppercase;
margin-top: 25px;
}
/*NAVIGATION BAR*/
nav {
position: relative;
list-style: none;
margin: 25px 0 40px 0;
padding: auto;
text-align: center;
font-family: Droid Serif;
text-transform: uppercase;
}
nav > ul > li {
display: inline;
}
nav > ul > li > a {
display: inline-block;
padding: 0 32px 0 32px;
color: #000;
text-decoration: none;
}
a:hover {
color: #00d8a3;
text-decoration: none;
transition: color 0.5s ease;
}
a:active {
color: #00d8a3 !important;
text-decoration: none;
}
/*BODY*/
h2 {
font-weight: 100;
text-align: center;
font-family: Droid Serif;
}
table {
border: 2px;
margin: -10px auto 15px auto;
}
td {
padding: 20px;
}
table tr td img {
-webkit-font-smoothing: antialiased;
opacity: 1;
-webkit-transition: opacity .3s ease-in-out;
-moz-transition: opacity .3s ease-in-out;
-o-transition: opacity .3s ease-in-out;
-ms-transition: opacity .3s ease-in-out;
transition: opacity .3s ease-in-out;
}
table tr td img:hover {
opacity: 0.7;
}
/*FOOTER*/
footer {
position: relative;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: 15px;
width: 100%;
clear: both;
}
#footer_line {
width: 90%;
border: 1px solid #696969;
margin: auto;
}
p {
margin-top: 0px;
text-align: center;
font-size: 0.6em;
}
#footer_bar {
text-transform: lowercase;
}
#footer_link {
color: #00d8a3;
text-decoration: none;
}
#footer_link:hover {
color: #000000;
text-decoration: none;
}
/*CONTACT FORM*/
label {
display: none;
margin-top: 20px;
letter-spacing: 2px;
}
form {
width: 437px;
margin: 0 auto;
}
#form-div {
background-color: e1e1e1;
padding: 35px 35px 50px 35px;
width: 450px;
float: left;
position: absolute;
margin-top: 20px;
margin-left: -260px;
}
input, textarea {
width: 400px;
height: 27px;
background-color: #ffffff;
border: 1px solid #efefef;
padding: 10px;
margin-top: 3px;
font-size: 0.9em;
color: #696969;
}
textarea {
height: 100px;
}
input:focus, textarea:focus {
border: 3px solid #00d8a3;
}
#submit {
border-radius: 5px;
background-color: #00d8a3;
width: 400px;
height: 50px;
margin: 0 auto 56px auto;
font-size: 1.5em;
font-weight: bold;
}
Here is an image of my homepage, I want the footer to be at the bottom of the contact page like in the homepage. http://puu.sh/bzOUo/e1f2479945.jpg
Here is how it is showing up in the contact page right now: http://puu.sh/bzOWZ/ef02a73399.png
Also, if someone can help me align the "send" button in the contact page with the rest of the input boxes, it'd be really nice.
Try absolute position on footer
footer
{
position: absolute;
bottom: 0;
width: 100%;
}
Here is the Demo
hope this will work out. add this to your css code :
footer {
position:fixed;
bottom:0;
left:0;
width:100%;
height:60px;
}
footer * {
display:inline;
}
I have a little problem with floating.
I need to display my links side by side with 20px margin, but it does not work.
CSS
ul li{
float:left;
display: inline-block;
position:relative;
padding:0 20px;
}
.link {
font-family: Tahoma;
font-size:18px;
overflow: hidden;
padding: 2px 0;
position: absolute;
cursor:pointer;
}
.link a{
text-decoration:none;
color:gray;
-webkit-transition: color 0.4s ease;
}
.link span {
position: inherit;
left:-100%;
bottom: 1px;
height: 1px;
width:100%;
background: #fb6f5e;
-webkit-transition:all 0.4s;
}
.link a:hover{
color:#fb6f5e;
}
.link:hover span {
overflow:hidden;
position: inherit;
bottom: 1px;
left:100%;
height: 1px;
width:100%;
background: #fb6f5ee;
-webkit-transition:all 0.4s;
}
HTML
<ul>
<li><div class="link">Start<span></span></div></li>
<li><div class="link">About<span></span></div></li>
<li><div class="link">Other<span></span></div></li>
<li><div class="link">Contact<span></span></div></li>
</ul>
http://jsfiddle.net/SD58Z/727/
This should do the trick:
Demo
Your link was set to position absolute so it was outside the flow of elements. Meaning all elements ended on top of each other.
You were also having some unclosed div tags and other html errors.
I moved some things around in the html to make it work. I do think this can be optimized. The reason why the underline hover effect did not work was because of my changes in the html structure (which I think is what you intended in the first place).
css
ul{
padding-left:0px;
}
ul li{
float:left;
display: block;
margin-left:20px;
position:relative;
color:inherit;
}
ul li:first-child{
margin-left:0px;
}
.link {
font-family: Tahoma;
font-size:18px;
overflow:hidden;
cursor:pointer;
}
.link a{
text-decoration:none;
color:gray;
-webkit-transition: color 0.4s ease;
position:relative;
overflow:hidden;
}
.link a:hover{
color:#fb6f5e;
}
.link span {
position: absolute;
left:-100%;
bottom: 1px;
height: 1px;
width:100%;
background: #fb6f5e;
-webkit-transition:all 0.4s;
}
.link:hover span {
bottom: 1px;
left:0%;
height: 1px;
width:100%;
background: #fb6f5ee;
-webkit-transition:all 0.4s;
}
Html:
<ul>
<li>
<div class="link">
<a href="#">Start
<span></span>
</a>
</div>
</li>
<li>
<div class="link">
<a href="#">About
<span></span>
</a>
</div>
</li>
<li>
<div class="link">
<a href="#">Other
<span></span>
</a>
</div>
</li>
<li>
<div class="link">
<a href="#">Contact
<span></span>
</a>
</div>
</li>
</ul>
You have a ton of syntax issues
extra </div> tags
Improper tag order: <a><div></a></div> should be <a><div></div></a>
Incorrect Hex code for background color on <span> in CSS
You are trying to float items and also absolute position them. Pick one or the other.
Using this CSS (i deleted 2 lines of code) it works fine.
JSFIDDLE: http://jsfiddle.net/SD58Z/725/
ul li{
float:left;
display: inline-block;
padding:0 20px;
}
.link {
font-family: Tahoma;
font-size:18px;
overflow: hidden;
padding: 2px 0;
cursor:pointer;
}
.link a{
text-decoration:none;
color:gray;
-webkit-transition: color 0.4s ease;
}
.link span {
position: inherit;
left:-100%;
bottom: 1px;
height: 1px;
width:100%;
background: #fb6f5e;
-webkit-transition:all 0.4s;
}
.link a:hover{
color:#fb6f5e;
}
.link:hover span {
overflow:hidden;
position: inherit;
bottom: 1px;
left:100%;
height: 1px;
width:100%;
background: #fb6f5ee;
-webkit-transition:all 0.4s;
}
With your HTML fixed: http://jsfiddle.net/SD58Z/732/
I just played with your code for a minute and fixed the HTML. There seems to be some useless CSS but this gets you going.
HTML
<ul class="nav">
<li><div class="link">Start<span></span></div></li>
<li><div class="link">About<span></span></div></li>
<li><div class="link">Other<span></span></div></li>
<li><div class="link">Contact<span></span></div></li>
</ul>
CSS
#nav {
width: 100%;
display: block;
}
ul li{
float:left;
display: inline-block;
padding:0 20px;
}
.link {
font-family: Tahoma;
font-size:18px;
overflow: hidden;
padding: 2px 0;
cursor:pointer;
}
.link a{
text-decoration:none;
color:gray;
-webkit-transition: color 0.4s ease;
}
.link span {
position: inherit;
left:-100%;
bottom: 1px;
height: 1px;
width:100%;
background: #fb6f5e;
-webkit-transition:all 0.4s;
}
.link a:hover{
color:#fb6f5e;
}
.link:hover span {
overflow:hidden;
position: inherit;
bottom: 1px;
left:100%;
height: 1px;
width:100%;
background: #fb6f5ee;
-webkit-transition:all 0.4s;
}