I have a div container with the ID of #homeSectionB, inside it there are articles all all of them have the class .testimonial.
What I am trying to do is that when you hover over one of the testimonial all of the other get an opacity of 0.60. I got it working view it live here: http://www.loaistudio.com/client-preview/Loai%20Design%20Studio
However, I am having a a problem, when you hover over the container all of the testimonials get that opacity class. How can I fix it? and make it only when you are actually hovering over one of the testimonials and not the container
And here is a fiddle: http://jsfiddle.net/svZ3C/
HTML:
<article class="testimonial">
<img alt="Neal Kilburne" src="assets/elements/neal-kilburne.jpg"/>
<section>
<h3>Neal Kilburne</h3>
<p>CEO, iTEQ Global www.iteqglobal.com</p>
<br>
<p>“Loai is a great asset to our company and provides us with great and quick responses, such a talented designer which we have the honour of working with.” 2011 - 2012</p>
</section>
</article>
<article class="testimonial">
<img alt="Vanessa Elharrar M.D" src="assets/elements/vanessa-elharrar.jpg"/>
<section>
<h3>Vanessa Elharrar M.D</h3>
<p>www.dreamcometruecoaching.com</p>
<br>
<p>"“It was wonderful to work with Loai on my website. He’s a really talented and gifted web designer, really creative and really has an eye for style and design. I loved the process of working with him, he’s a really nice guy and I do recommend him. I think you’ll love the outcome. I was very impressed and would use him again in a heartbeat.”" November 25, 2012</p>
</section>
</article>
<article class="testimonial">
<img alt="Glen Eric Huysamer" src="assets/elements/glen-eric-huysamer.jpg"/>
<section>
<h3>Glen Eric Huysamer</h3>
<p>Specialist Service Provider.</p>
<br>
<p>“I would like to take this opportunity to warn people who might consider using Loai Design Studio. You will have to buckle up & strap yourself in as this young designer & associates take you through the process of creating your design needs. I was pleasantly surprised from start to finish, & can say that even though Loai took control of the creative process the end result felt like it was mine. You can not go wrong with this young lad, go ahead surprise yourself”. December 30, 2011</p>
</section>
</article>
</div><div id="grid2"><!-----Gird 2----->
<article class="testimonial">
<img alt="Geeta Martinez" src="assets/elements/geeta-martinez.jpg"/>
<section>
<h3 >Geeta Martinez</h3>
<p>Lawyer & Business Consultant</p>
<br>
<p>"Leo did a great job! He designed & put together several websites for me in less than a week. He was incredibly patient & flexible throughout the whole process, & took a lot of the stress out of the whole situation for me. He is a really nice guy to work with - I really appreciated his approach! I would definitely recommend working with him". July 14, 2013</p>
</section>
</article>
<article class="testimonial">
<img alt="Phil Turtle" src="assets/elements/phil-turtle.jpg"/>
<section>
<h3>Phil Turtle</h3>
<p>www.turtleconsulting.com</p>
<br>
<p>“When we needed a new logo for our business operation (Data Center Industry PR). We needed somebody to help to try to encapsulate what a Data Center is, into a very simple logo. As many people don not even know what a Data Center is that was not an easy challenge. But Loai Design stepped up and within two days we had several ideas from which to choose, we worked on the chosen one of those and very quickly indeed we had a full working logo and our ecommerce site up and running. Thank You Loai Design.” July 11, 2013</p>
</section>
</article>
<article class="testimonial">
<section>
<h3>Richard Jackson</h3>
<p>Photographer www.rjpstudios.co.uk</p>
<br>
<p>“Loai designed my website last year though I could have done it myself loai added a proffesional touch to the design which is so important in creating the best first impeson.” 2013</p>
</section>
</article>
</div><div id="grid3"><!-----Gird 3----->
<article class="testimonial">
<img alt="Lulu Oliver" src="assets/elements/lulu-oliver.jpg"/>
<section>
<h3>Lulu Oliver</h3>
<p>www.lusialpacas.co.uk</p>
<br>
<p>"He is the most fantastic young man, he is talented, clever and extremely helpful. He Put my whole package together, he designed the website well. and now I have a website that I can mange my self and it just have everything I wanted to do. So I can't recommend him highly enough, he really is a really good guy, and if you want some help or you want him to do your website, that is the place to go!” Mar 26, 2013</p>
</section>
</article>
<article class="testimonial">
<img alt="Alina Kouneva Tremblay" src="assets/elements/alina-kouneva-tremblay.jpg"/>
<section>
<h3>Alina Kouneva Tremblay</h3>
<p>www.alinagardens.com</p>
<br>
<p>"I had the honor and the privilege to work with Loai on my website. I have been looking for a web designer, who can simply just do what I wanted and put it in a website so that my customers had access to my work. He was wonderful to work with, as much he's a professional, he's also just a great guy and very easy to work with. I remember laughing lot with him and it's always a nice thing to do, becouse websites can be a bit stressfull. I love my website, my friends love my website, my business associate love my website, and I simply want everybody to love their websites as much as I do. So I highly recommend Loai for your next website!” April 5, 2013</p>
</section>
</article>
</div>
</div>
</div>
CSS:
/*HOME PAGE -> Section E*/
.testimonial {
background-color: #F7F7F7;
border: 1px solid #149B78;
margin-bottom: 20px;
text-align: center;
-webkit-transition: opacity 0.4s ease;
-moz-transition: opacity 0.4s ease;
-ms-transition: opacity 0.4s ease;
-o-transition: opacity 0.4s ease;
transition: opacity 0.4s ease;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
}
.testimonial section {
padding: 20px;
}
.testimonial section h3 {
color: #1AC99C;
}
.testimonial section p {
font-size: 0.90em;
}
.testimonial section p:first-of-type {
color: #149B78;
}
.testimonial img {
border-bottom: 1px dashed #435D84;
padding: 1px;
}
/*The hover-over animation*/
#homeSectionB:hover .testimonial {
opacity: 0.60;
-moz-opacity: 0.60;
-khtml-opacity: 0.60;
filter:alpha(opacity=60);
}
#homeSectionB:hover .testimonial:hover {
opacity: 1;
-webkit-box-shadow: 0px 0px 20px 0px rgba(14,109,85,0.3);
-moz-box-shadow: 0px 0px 20px 0px rgba(14,109,85,0.3);
box-shadow: 0px 0px 20px 0px rgba(14,109,85,0.3);
}
We have this setup working (check out the nav bar on http://firststop.herokuapp.com), and I know the problem you want to fix is to have the opacity only work if you hover over one of the elements (not the container)
Although I don't have a direct solution, I have a way which works well enough for your users to not notice anything
CSS Child & Sibling Selectors
We spent a long time looking over the mechanics of CSS child & sibling selectors, trying to get them to work to achieve your desired result. The issue is that you cannot select siblings on hover; you can only select children:
.container:hover .children{
/* Works */
}
.child:hover .other_children {
/* Not Works */
}
Might be wrong, but that's the problem you have -- that you have to style from the container - down
Use Padding
So our fix was to replace margin with padding, meaning that if you went into the container with your mouse, you had to hover over one of the elements
We took our elements & created a mini-container for them. This was display:inline-block, and had padding: Xpx
I updated your jsFiddle to show these fixes:
article {
padding-bottom: 20px;
-webkit-transition: opacity 0.4s ease;
-moz-transition: opacity 0.4s ease;
-ms-transition: opacity 0.4s ease;
-o-transition: opacity 0.4s ease;
transition: opacity 0.4s ease;
}
.testimonial {
background-color: #F7F7F7;
border: 1px solid #149B78;
text-align: center;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
}
/*The hover-over animation*/
#homeSectionB:hover article {
opacity: 0.10;
-moz-opacity: 0.10;
-khtml-opacity: 0.10;
filter:alpha(opacity=10);
}
#homeSectionB:hover article:hover {
opacity: 1;
-webkit-box-shadow: 0px 0px 20px 0px rgba(14,109,85,0.3);
-moz-box-shadow: 0px 0px 20px 0px rgba(14,109,85,0.3);
box-shadow: 0px 0px 20px 0px rgba(14,109,85,0.3);
}
<article >
<div class="testimonial">
<img alt="Neal Kilburne" src="assets/elements/neal-kilburne.jpg"/>
<section>
<h3>Neal Kilburne</h3>
<p>CEO, iTEQ Global www.iteqglobal.com</p>
<br>
<p>“Loai is a great asset to our company and provides us with great and quick responses, such a talented designer which we have the honour of working with.” 2011 - 2012</p>
</section>
</div>
</article>
Your problem styles are these:
#homeSectionB:hover .testimonial {
opacity: 0.60;
-moz-opacity: 0.60;
-khtml-opacity: 0.60;
filter: alpha(opacity=60);
}
You've clearly specified that all testimonials should get an opacity of 0.60 when someone hovers on the div#homeSectionB. Now, I understand that you have done this because you wanted to fade out other testimonials when someone hovered over one of them. This would have worked if you didn't have any gutter width.
There are multiple ways to resolve this issue now. Let me know if you are okay with a JS approach or want a CSS-only one.
UPDATE 1:
Here you go: http://jsfiddle.net/svZ3C/5/ . The principle involved here is that you need to use padding in place of margin. Here are the updated CSS rules:
article {
padding-bottom: 20px;
-webkit-transition: opacity 0.4s ease;
-moz-transition: opacity 0.4s ease;
-ms-transition: opacity 0.4s ease;
-o-transition: opacity 0.4s ease;
transition: opacity 0.4s ease;
}
#grid1 article {
padding-right: 15px;
}
#grid2 article {
padding: 0 5px 20px 5px;
}
#grid3 article {
padding-left: 15px;
}
/*Don't modify articles. Modify testimonials within them.*/
#homeSectionB:hover .testimonial {
opacity: 0.10;
-moz-opacity: 0.10;
-khtml-opacity: 0.10;
filter:alpha(opacity=10);
}
#homeSectionB:hover .testimonial:hover {
opacity: 1;
-webkit-box-shadow: 0px 0px 20px 0px rgba(14, 109, 85, 0.3);
-moz-box-shadow: 0px 0px 20px 0px rgba(14, 109, 85, 0.3);
box-shadow: 0px 0px 20px 0px rgba(14, 109, 85, 0.3);
}
and slight change in the HTML is this:
<article>
<div class="testimonial" <img alt="Neal Kilburne" src="assets/elements/neal-kilburne.jpg" />
<section>
<h3>Neal Kilburne</h3>
<p>CEO, iTEQ Global www.iteqglobal.com</p>
<br>
<p>“Loai is a great asset to our company and provides us with great and quick responses, such a talented designer which we have the honour of working with.” 2011 - 2012</p>
</section>
</div>
</article>
Related
OK, so I didn't want to use flexboxes to begin with because of the older browser support issues but the only way I could get it working without flexbox involved floats, -margins, z-indexs, and was just very ugly and unseenly.
That being said, with flexbox, the left hand date block contorts both its width and height in both IE and Chrome despite hard setting the height and width.
https://jsfiddle.net/yuum08d9/
<style>
body {
font: 13px / 23px Roboto, sans-serif;
}
#Experience {
}
#Experience h4 {
color: #262626;
font: normal normal 300 normal 23px / 29.12px Roboto, sans-serif;
margin: 0px 0px 30px;
}
#Experience .Experience {
box-sizing: border-box;
color: #404040;
display: flex;
margin: 0 0 30px 0;
padding: 20px 0 0 0;
transition: all 600ms ease;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-o-transition: all 600ms ease;
}
#Experience .Experience:Hover {
transform: translateX(20px);
-webkit-transform: translateX(20px);
-moz-transform: translateX(20px);
-o-transform: translateX(20px);
transform: translateY(-20px);
-webkit-transform: translateY(-20px);
-moz-transform: translateY(-20px);
-o-transform: translateY(-20px);
transition: all 600ms ease;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-o-transition: all 600ms ease;
}
#Experience .Experience .Date {
height: 160px;
width: 172px;
position: relative;
display: block;
}
#Experience .Experience .Date div {
bottom: -1.5px;
transform: matrix(1, 0, 0, 1, 20, -20);
background: #f1f1f1;
transition: all 600ms ease;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-o-transition: all 600ms ease;
}
#Experience .Experience:Hover .Date Div {
background: #4dbfd9;
box-shadow: 3px 0px 7px 0px rgba(0, 0, 0, 0.05);
transition: all 600ms ease;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-o-transition: all 600ms ease;
}
#Experience .Experience .Date h6 {
color: #262626;
letter-spacing: 0.8px;
font: normal normal bold normal 15px / 24.44px Roboto, sans-serif;
margin: 0px;
padding: 56.75px 0px;
text-align: center;
transition: all 600ms ease;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-o-transition: all 600ms ease;
}
#Experience .Experience:Hover .Date h6 {
color: #fff;
transition: all 400ms ease;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-o-transition: all 600ms ease;
}
#Experience .Experience .Date .Angle {
position: absolute;
right: 0;
top: 142px;
transform: matrix(1, 0, 0, 1, 20, 0);
border-top: 20px solid #DAD6D6;
border-right: 20px solid #fff;
border-bottom: 0px solid #fff;
border-left: 0px solid #fff;
}
#Experience .Experience .WorkExperience {
box-shadow: rgb(221, 221, 221) 0.5px 0.5px 5px 0px;
box-sizing: border-box;
color: #404040;
font: 13px / 23px Roboto, sans-serif;
padding: 20px 55px;
text-align: left;
}
#Experience .Experience .WorkExperience h6 span {
font-size: 14px;
padding: 2px 0 0 10px;
}
#Experience .Experience .WorkExperience h6 {
color: rgb(38, 38, 38);
font-weight: 900;
font: 17px / 26px Roboto, sans-serif;
margin: 9px 0 0 0;
}
#Experience .Experience .WorkExperience p {
font: 13px / 23px Roboto, sans-serif;
}
#Experience .Experience .WorkExperience ul {
list-style:disc;
}
</style>
<div id="Experience" class="Block">
<h4>
Work Experience
</h4>
<div class="Experience">
<div class="Date">
<div>
<h6 class="H6">January 2015 -<br />Present</h6>
</div>
<span class="Angle"></span>
</div>
<div class="WorkExperience">
<h6>Boundary Protection Engineering <span>U.S. Air Force</span></h6>
<p>System Administrator of $10 billion United States Air Force Intra-Network (AFIN) Boundary Protection Cyberspace Security and Control System Weapon System (CSCS/WS) responsible for 1,070 firewalls, proxies, and VPN’s across 121 geographically separated locations in order to evaluate, detect, prevent and implement countermeasures to protect clients, networks, and data & voice systems to include Secure Internet Protocol Routing (SIPR) network mission systems from unauthorized network activity.</p>
<ul>
<li>Directed 624th Operations Command (OC) U.S. Cyber Command (USCYBERCOM) mission mapping 83rd Network Operations Squadron (NOS) key weapon systems paving future for Defensive Cyber Operations (DCO) missions.</li>
<li>Bolstered data mining capabilities by 55% by meticulously developing new Electronically Stored Information (ESI) requests logging/search process.</li>
<li>Promptly identified and resolved critical Air Force Security Assistance Center (AFSAC) service outage identifying and resolving 8 firewall security tunnel circuits enabling $166B global peacekeeping operations.</li>
</ul>
</div>
</div>
<!-- divider -->
<div class="Experience">
<div class="Date">
<div>
<h6 class="H6">August 2013 -<br />January 2015</h6>
</div>
<span class="Angle"></span>
</div>
<div class="WorkExperience">
<h6>Information System Security Officer/Information System Security Engineer<span>U.S. Air Force</span></h6>
<p>System administrator/manager responsible for ensuring confidentiality, integrity, and availability of systems and networks and data through the utilization of risk analysis process. Responsibilities include obtaining/maintaining Information System accreditation (SSPS/ISSP), integrate disaster recovery/contingency planning, establish a security education, training, and awareness program, create configuration management (CM) process and conduct auditing & network monitoring.</p>
<ul>
<li>Collaborated with HQ to develop 15 new policies and update 28 procedures to include: contingency planning, user training, configuration management, and auditing, in accordance with JSIG/JAFAN PL-2 requirements; skilled at complex information systems, i.e. Multi-Program Interconnection, PL-2 systems, and above, development of IA Policies and Procedures, and preparation of C&A documents and procedures; lauded by PACAF inspectors as "most improved".</li>
<li>Coordinated massive network overhaul replacing/upgrading ~90% of network infrastructure in order to comply with PL-2 IS requirements achieving approximately 99.8% system uptime. (Up from 88%)</li>
<li>Developed and implemented custom scripts throughout entire IS enabling highly customized real-time auditing/reporting of all information systems (ISs) improving ISSM/ISSO awareness while meeting JSIG/JAFAN auditing requirements. </li>
</ul>
</div>
</div>
<!-- divider -->
<div class="Experience">
<div class="Date">
<div>
<h6 class="H6">June 2013 -<br />August 2013</h6>
</div>
<span class="Angle"></span>
</div>
<div class="WorkExperience">
<h6>Communications Focal Point Technician<span>U.S. Air Force</span></h6>
<p>System administrator/manager responsible for ensuring confidentiality, integrity, and availability of systems and networks and data through the utilization of risk analysis process. Responsibilities include obtaining/maintaining Information System accreditation (SSPS/ISSP), integrate disaster recovery/contingency planning, establish a security education, training, and awareness program, create configuration management (CM) process and conduct auditing & network monitoring.</p>
<ul>
<li>Accountable for maintaining physical accountability of AFIN equipment, planning, and scheduling production, ordering, and management of materials, and track/order preventive maintenance.</li>
<li>Conducted Tier I/II help desk support; directly involved in the resolution of 500+ tickets.</li>
<li>Effectively provided technical support, in person, on phone and through online communication cutting ticket creation by approximately 12% in less than 3 months.</li>
<li>Successfully developed and implemented new ticket monitoring and reporting system cutting reporting time by nearly 80%.</li>
<li>Improved network vulnerability awareness by approximately 30% by effectively developing and implementing vulnerability and patching monitoring system.</li>
</ul>
</div>
</div>
<!-- divider -->
<div class="Experience">
<div class="Date">
<div>
<h6 class="H6">June 2013 -<br />August 2013</h6>
</div>
<span class="Angle"></span>
</div>
<div class="WorkExperience">
<h6>Network Control Center Technician<span>U.S. Air Force</span></h6>
<p>System administrator of $318 million network for 35th Fighter Wing supporting 44 units throughout Japan. Responsibilities include managing core network services including Active Directory, Group Policy, DNS, and DHCP. Other responsibilities included system lifecycle management, vulnerability identification/remediation, and tier 3 support.</p>
<ul>
<li>Team leader for windows domain migration project, to incorporate local base network into Air Force Intra-Network (AFIN) -- lauded "Best to Date" migration by Higher Headquarters Communications and Information Director.</li>
<li>Developed the vulnerability management & mitigation rapid resolution program resulting in the identification and resolution of over 25,000 vulnerabilities in less than 2 weeks.</li>
<li>Developed Batch/PowerShell script suite used to identify/correct operating system errors, perform customized system maintenance, remediate patching shortfalls, and detect OS vulnerabilities resulting in 25% drop in tier 1 tickets and 22% improvement in patching, and improved system life cycle.</li>
</ul>
</div>
</div>
<!-- divider -->
</div>
For the Date item to keep its width and not shrink to fit (which is the default), you need to set flex-shrink: 0
#Experience .Experience .Date {
flex-shrink: 0; /* added */
height: 160px;
width: 172px;
position: relative;
display: block;
}
Updated fiddle
I had faced a similar problem with flex which also included an issue with absolutely positioned child divs inside flex containers in Firefox. Thus I would advice against using flex because of the reason you stated as well cross browser compatibility.
So I dropped flex and used the metrics vw, vh and vmin( vm for IE ) instead. These units are tied in with the viewport and allow for fluidic layouts with elegant code. You can even use these units with fonts for a more responsive design.
Here's a JSFiddle demonstrating this. It runs in all browsers and is responsive as well.
And here's the code
body {
font: 13px / 23px Roboto, sans-serif;
}
#Experience {
}
#Experience h4 {
color: #262626;
font: normal normal 300 normal 23px / 29.12px Roboto, sans-serif;
}
.H6{
text-align: center;
display: inline-block;
border: 2px solid #404040;
width: 20vw;
float: left;
background-color: #f1f1f1;
margin: 2vw;
}
.WorkExperience{
border: 2px solid #404040;
width: 50vw;
margin-left: 18vw;
padding: 2vw;
}
<div id="Experience" class="Block">
<h4>
Work Experience
</h4>
<div class="Experience">
<div class="Date">
<div>
<h6 class="H6">January 2015 -<br />Present</h6>
</div>
<span class="Angle"></span>
</div>
<div class="WorkExperience">
<h6>Boundary Protection Engineering <span>U.S. Air Force</span></h6>
<p>System Administrator of $10 billion United States Air Force Intra-Network (AFIN) Boundary Protection Cyberspace Security and Control System Weapon System (CSCS/WS) responsible for 1,070 firewalls, proxies, and VPN’s across 121 geographically separated locations in order to evaluate, detect, prevent and implement countermeasures to protect clients, networks, and data & voice systems to include Secure Internet Protocol Routing (SIPR) network mission systems from unauthorized network activity.</p>
<ul>
<li>Directed 624th Operations Command (OC) U.S. Cyber Command (USCYBERCOM) mission mapping 83rd Network Operations Squadron (NOS) key weapon systems paving future for Defensive Cyber Operations (DCO) missions.</li>
<li>Bolstered data mining capabilities by 55% by meticulously developing new Electronically Stored Information (ESI) requests logging/search process.</li>
<li>Promptly identified and resolved critical Air Force Security Assistance Center (AFSAC) service outage identifying and resolving 8 firewall security tunnel circuits enabling $166B global peacekeeping operations.</li>
</ul>
</div>
</div>
This question already has answers here:
css transition opacity fade background
(4 answers)
Closed 7 years ago.
I have an image on my home page (or index.html) and I want to be able to hover over the image then a black image fades on with a low opacity.
Example: http://wethepeoplebmx.de/hardgoods - if you go to hover over one of the images (or products), you can see the fade sort of thing I am trying to acomplish. I am fairly new at HTML and CSS, along with scripts and stuff like that. I'm assuming it's something to do with CSS, eg, hover, etc.
Thanks in advance
You can do this with CSS3 animations and :hover.
.wrap {
width: 100px;
height: 100px;
position: relative;
}
.effect {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
background: none;
/* First we need to help some browsers along for this to work.
Just because a vendor prefix is there, doesn't mean it will
work in a browser made by that vendor either, it's just for
future-proofing purposes I guess. */
-o-transition: .5s;
-ms-transition: .5s;
-moz-transition: .5s;
-webkit-transition: .5s;
/* ...and now for the proper property */
transition: .5s;
}
.effect:hover {
background: rgba(0, 0, 0, 0.4);
}
<div class="wrap">
<img src="http://placehold.it/100x100">
<div class="effect"></div>
</div>
I think you want something like this -
.wrap{position:relative;height: 100px;width: 120px;}
.wrap img{width: 100%;;height: 100%;}
.effect{background: rgba(0, 0, 0, .5);;position: absolute;height: 100%;width: 100%;;top:0;display: none;}
.wrap:hover .effect{display: block;opacity:.4}
<div class="wrap">
<img src="http://t0.gstatic.com/images?q=tbn:ANd9GcQiWGXo4U6CCvNItlDYFgEQz4d3T-YjLj13nqUZ-crpAr3qMPx-">
<div class="effect">
text
</div>
</div>
I have some pretty basic accordion tabs that open when clicked and close when you click another one. I want them to be able to close when you click on the tab that is open as well though. Does anyone know how to do this?
.ac-container {
// max-width: 400px;
}
.ac-container label {
// height: 30px !important;
line-height: 21px !important;
// font-size: 12px !important;
padding: 5px 20px;
text-transform: uppercase;
font-weight: 100;
position: relative;
z-index: 20;
display: block;
height: 30px;
cursor: pointer;
color: white;
line-height: 33px;
font-size: 19px;
background: $dark-blue;
border-bottom: 2px solid $light-blue;
height: auto;
line-height: 20px;
}
.ac-container span {
position:absolute;
bottom:5px;
right:8px;
}
.ac-container {
width: 100%;
// margin: 10px auto 30px auto;
text-align: left;
}
.ac-container label:hover {
background: $light-blue;
color:$dark-blue;
}
.ac-container input:checked + label,.ac-container input:checked + label:hover {
background: $dark-blue;
color: white;
text-transform: uppercase;
font-weight: 100;
height: auto;
line-height: 21px;
font-size: 19px;
}
.ac-container label:hover:after,.ac-container input:checked + label:hover:after {
content: '';
position: absolute;
width: 24px;
height: 24px;
right: 13px;
top: 7px;
// background: transparent url(../images/arrow_down.png) no-repeat center center;
}
.ac-container input:checked + label:hover:after {
// background-image: url(../images/arrow_up.png);
}
.ac-container input {
display: none;
}
.ac-container article {
background: rgba(255,255,255,0.5);
margin-top: -1px;
overflow: hidden;
height: 0;
position: relative;
z-index: 10;
-webkit-transition: height 0.3s ease-in-out,box-shadow 0.6s linear;
-moz-transition: height 0.3s ease-in-out,box-shadow 0.6s linear;
-o-transition: height 0.3s ease-in-out,box-shadow 0.6s linear;
-ms-transition: height 0.3s ease-in-out,box-shadow 0.6s linear;
transition: height 0.3s ease-in-out,box-shadow 0.6s linear;
}
.ac-container article p {
font-style: normal;
color: #777;
line-height: 23px;
font-size: 100%;
padding: 20px;
text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
}
.ac-container input:checked ~ article {
-webkit-transition: height 0.5s ease-in-out,box-shadow 0.1s linear;
-moz-transition: height 0.5s ease-in-out,box-shadow 0.1s linear;
-o-transition: height 0.5s ease-in-out,box-shadow 0.1s linear;
-ms-transition: height 0.5s ease-in-out,box-shadow 0.1s linear;
transition: height 0.5s ease-in-out,box-shadow 0.1s linear;
box-shadow: 0 0 0 1px rgba(155,155,155,0.3);
}
.ac-container input:checked ~ article.ac-small {
height: 140px;
}
.ac-container input:checked ~ article.ac-medium {
height: 180px;
}
.ac-container input:checked ~ article.ac-large {
height: 230px;
}
<section class="ac-container">
<h2>Breakfast</h2>
<div>
<input id="ac-1" name="accordion-1" type="radio" >
<label for="ac-1"><img src="img/breakfast/american.jpg" alt=""><span>American</span></label>
<article class="ac-small">
<p>Well, the way they make shows is, they make one show. That show's called a pilot. Then they show that show to the people who make shows, and on the strength of that one show they decide if they're going to make more shows.</p>
</article>
</div>
<div>
<input id="ac-2" name="accordion-1" type="radio">
<label for="ac-2"><img src="img/breakfast/continental.jpg" alt=""></i><span>Continental</span></label>
<article class="ac-medium">
<p>Like you, I used to think the world was this great place where everybody lived by the same standards I did, then some kid with a nail showed me I was living in his world, a world where chaos rules not order, a world where righteousness is not rewarded. That's Cesar's world, and if you're not willing to play by his rules, then you're gonna have to pay the price. </p>
</article>
</div>
<div>
<input id="ac-3" name="accordion-1" type="radio">
<label for="ac-3"><img src="img/breakfast/english.jpg" alt=""><span>English</span></label>
<article class="ac-large">
<p>You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man. </p>
</article>
</div>
<div>
<input id="ac-4" name="accordion-1" type="radio">
<label for="ac-4"><img src="img/breakfast/health.jpg" alt=""><span>The Healthy Stuff</span></label>
<article class="ac-large">
<p>You see? It's curious. Ted did figure it out - time travel. And when we get back, we gonna tell everyone. How it's possible, how it's done, what the dangers are. But then why fifty years in the future when the spacecraft encounters a black hole does the computer call it an 'unknown entry event'? Why don't they know? If they don't know, that means we never told anyone. And if we never told anyone it means we never made it back. Hence we die down here. Just as a matter of deductive logic. </p>
</article>
</div>
<div>
<input id="ac-5" name="accordion-1" type="radio">
<label for="ac-5"><img src="img/breakfast/misc.jpg" alt=""><span>Miscellaneous</span></label>
<article class="ac-large">
<p>You see? It's curious. Ted did figure it out - time travel. And when we get back, we gonna tell everyone. How it's possible, how it's done, what the dangers are. But then why fifty years in the future when the spacecraft encounters a black hole does the computer call it an 'unknown entry event'? Why don't they know? If they don't know, that means we never told anyone. And if we never told anyone it means we never made it back. Hence we die down here. Just as a matter of deductive logic. </p>
</article>
</div>
</section>
Your code doesn't work.
Your HTML doesn't have H4 tag.
Here's a working sample that works like you wanted.
$(document).ready(function() {
$('.accordion-title').click(function() {
if ($(this).hasClass('active')) {
$(this).removeClass('active').next('.accordion-content').slideUp();
} else {
$('.accordion-title').removeClass('active');
$('.accordion-content').slideUp();
$(this).addClass('active').next('.accordion-content').slideDown();
}
});
});
.accordion-title {
font-size: 14px;
font-weight: bold;
border: 1px solid black;
}
.accordion-content {
border: 1px solid black;
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="accordion-title">Title</div>
<div class="accordion-content">Content</div>
<div class="accordion-title">Title 2</div>
<div class="accordion-content">Content 2</div>
<div class="accordion-title">Title 3</div>
<div class="accordion-content">Content 3</div>
View on JSFiddle
Use input type checkbox instead of radio and write styles in css to make height zero when unchecked.
<section class="ac-container">
<h2>Breakfast</h2>
<div>
<input id="ac-1" name="accordion-1" type="checkbox" >
<label for="ac-1"><img src="img/breakfast/american.jpg" alt=""> <span>American</span></label>
<article class="ac-small">
<p>Well, the way they make shows is, they make one show. That show's called a pilot. Then they show that show to the people who make shows, and on the strength of that one show they decide if they're going to make more shows.</p>
</article>
</div>
<div>
<input id="ac-2" name="accordion-1" type="checkbox">
<label for="ac-2"><img src="img/breakfast/continental.jpg" alt=""></i><span>Continental</span></label>
<article class="ac-medium">
<p>Like you, I used to think the world was this great place where everybody lived by the same standards I did, then some kid with a nail showed me I was living in his world, a world where chaos rules not order, a world where righteousness is not rewarded. That's Cesar's world, and if you're not willing to play by his rules, then you're gonna have to pay the price. </p>
</article>
</div>
<div>
<input id="ac-3" name="accordion-1" type="checkbox">
<label for="ac-3"><img src="img/breakfast/english.jpg" alt=""><span>English</span></label>
<article class="ac-large">
<p>You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man. </p>
</article>
</div>
<div>
<input id="ac-4" name="accordion-1" type="checkbox">
<label for="ac-4"><img src="img/breakfast/health.jpg" alt=""><span>The Healthy Stuff</span></label>
<article class="ac-large">
<p>You see? It's curious. Ted did figure it out - time travel. And when we get back, we gonna tell everyone. How it's possible, how it's done, what the dangers are. But then why fifty years in the future when the spacecraft encounters a black hole does the computer call it an 'unknown entry event'? Why don't they know? If they don't know, that means we never told anyone. And if we never told anyone it means we never made it back. Hence we die down here. Just as a matter of deductive logic. </p>
</article>
</div>
<div>
<input id="ac-5" name="accordion-1" type="checkbox">
<label for="ac-5"><img src="img/breakfast/misc.jpg" alt=""><span>Miscellaneous</span></label>
<article class="ac-large">
<p>You see? It's curious. Ted did figure it out - time travel. And when we get back, we gonna tell everyone. How it's possible, how it's done, what the dangers are. But then why fifty years in the future when the spacecraft encounters a black hole does the computer call it an 'unknown entry event'? Why don't they know? If they don't know, that means we never told anyone. And if we never told anyone it means we never made it back. Hence we die down here. Just as a matter of deductive logic. </p>
</article>
</div>
</section>
Dear Stackoverflow readers,
Using only CSS3, is there any way to change the text of a div after the transition is completed?
My code snippet can be viewed here:
HTML
<div class="biography">
<p>Hover For Player Info</p>
</div>
CSS3
.biography {
width: 100px;
height: 60px;
float: left;
margin: 5px;
background: #3399FF;
color: #ffffff;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
position: relative;
right: 5%;
font-weight: bold;
font-size: 15px;
text-align: center;
padding: 10px;
border-radius: 5px;
opacity: 0.4;
transition: all 0.6s ease;
-webkit-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
}
.biography:hover {
width: 350px;
height: 450px;
margin: 10px 10px 0px -200px;
opacity: 1;
background: #7C7C7C;
}
JSFiddle
After the transition, I want to change "Hover For Player Info" to "Player Info".
Continuing on that, I need it to change back to "Hover For Player Info" once the mouse is no longer hovering over the div.
If there's no possible way, what skills do I need to learn to achieving what I want?
Thanks in advance!
Using jQuery:
$('.biography').hover(function(e) {
$(this).html('Player Info');
}, function(e) {
$(this).html("Hover for Player Info");
});
JSFiddle Demo
This can be done in CSS alone using :after:
.biography:after{
content:'Hover for player info';
}
.biography:hover:after{
content:'Player Info';
}
On .biograhpy hover, the content changes, and no JS is required!
JSFiddle Demo
#Tony Hello again. :) I hope your project is going well.
#Faiz has given you a good solution, but it changes the text on hover, not when the animation is complete (as you asked for in your original question). If his solution works for you, awesome; if you still want the text to change when the transition is complete, here's the code for that below and here's a working jsFiddle based off the one Faiz gave above.
$('.biography').on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(e) {
if ($(e.target).css('opacity') == 1) { // or any other style from the "hover" form
$(".player-info-msg").html('Player Info');
} else {
$(".player-info-msg").html('Hover for Player Info');
}
});
Let me know if you have any problems if you decide to implement this, and let me know if you have any further questions.
EDIT: If you want to read up more on this event, see the Mozilla docs. If you want to know more about jQuery, Javascript, etc. all of the resources #Faiz gave you are great.
Using the onTransitionEnd event helps a lot
Transition and animation have events event attached to dem
i'm trying to enable the :target on some element, and it seems to work on IE, Firefox, and even Chrome on my phone, but somehow it wont work on my Chrome Desktop. any suggestions?
HTML (deleted the irrelevant code) :
<nav class="main-nav" id="main-nav">
THE GYM
</nav>
<div class="page-wrap">
<div class="content">
<div class="gym" id="gym"></div>
</div>
</div>
CSS:
.gym {
z-index:3;
position:fixed;
height:200px;
width:100%;
background:#fff;
bottom:0;
left:0;
box-shadow:2px 4px 4px rgba(0, 0, 0, 0.4);
margin-bottom:-200px;
transition: margin-bottom ease 1s;
-webkit-transition: margin-bottom ease 1s;
-o-transition: margin-bottom ease 1s;
-moz-transition: margin-bottom ease 1s;
}
#gym:target {
margin-bottom: 0;
}
By the way, when i tried to do this method with JS, with the .css function, it won't even work...the site is on boazkerengil.com
I don't know that anything is broken. It's just a white box that appears, correct? If so, it is working. Here is a screen recording of what happens: http://cl.ly/VWDf. I am using Chrome Mac 34.0.1847.137.