CSS transition - only working in one direction, needs to be both - css

I have a CSS transition which takes place on hover of a link - the transition happens to some of the contents of this link.
My issue is that the transition (which primarily animates width and height properties) works fine when hovering over the link, but on stopping hover, the elements simply spring back to their unhovered state - rather than transitioning.
The styles defined are this:
a.transition {
display: block;
width: 300px;
height: 200px;
position: relative;
border: 1px solid #000;
color: #000'
}
a.transition .category_info_container {
position: absolute;
left: 0;
right: 0;
top: 0;
height: 70px;
transition: height 0.5s, width 0.5s, color 0.5s;
}
a.transition .category_info_container .category_info {
background-color: #aaa;
padding: 0 20px;
}
a.transition .category_info_container .category_info .category_name {
color: #fff;
text-transform: uppercase;
font-size: 18px;
line-height: 70px;
}
a.transition .category_info_container .category_info .category_desc {
display: none;
}
a.transition:hover .category_info_container {
background: #eee;
width: 48%;
height: 100%;
}
a.transition:hover .category_info_container .category_info {
position: absolute;
bottom: 20%;
background: none;
}
a.transition:hover .category_info_container .category_info .category_name {
color: #000;
line-height: 50px;
}
a.transition:hover .category_info_container .category_info .category_desc {
display: block;
}
And my markup:
<a href="#" class="transition">
<div class="category_info_container">
<div class="category_info">
<div class="category_name">
Test Name
</div>
<div class="category_desc">
Lorem ipsum dolar sit amet...
</div>
</div>
</div>
</a>
I have created a JSFiddle with my code.

I think, It will be better, if you use different blocks for elements:
checkout my example:
http://jsfiddle.net/bo5o3q18/3/
<a href="#" class="transition">
<div class="category_info">
<div class="category_name">
Test Name
</div>
</div>
<div class="category_info-add">
<div class="category_name">
Test Name
</div>
<div class="category_desc">
Lorem ipsum dolar sit amet...
</div>
</div>
</a>

Related

How to create a css vertical line with circles and text on side in reactjs?

Hi I have been trying to create something as showing in the image below but I do not know if my way of doing is correct or not, if not could you please correct me.
Thanks
please see the code I have tried:
<Box className="education-details">
<div className="circle"> </div>
<div className="not-circle">
<p className="education-degree">masters</p>
<p className="education-year"> 2017/2019</p>
<p className="education-location">Dublin business school</p>
</div>
<div className="circle"> </div>
<div className="not-circle">
<p className="education-degree">masters</p>
<p className="education-year"> 2017/2019</p>
<p className="education-location">Dublin business school</p>
</div>
<div className="circle"> </div>
<div className="not-circle">
<p className="education-degree">masters</p>
<p className="education-year"> 2017/2019</p>
<p className="education-location">Dublin business school</p>
</div>
</Box>
the CSS part
.education-details {
box-sizing: border-box;
}
.circle {
width: 17px;
height: 17px;
background-color: rgb(255, 0, 0);
border-radius: 50%;
margin-left: -1.75%;
position: absolute;
}
.not-circle {
/* margin-top: -30px;
margin-left: 1.5vw; */
}
The result
codesand box link
Finally, as your question was quite interesting, I played with codepen.io to create something similar to your original picture. I reduced a bit the HTML content like I mentionned in my comment as I prefer using pseudo-elements when possible for graphical concerns.
The HTML sementic could be improved by the use of <section>, <ul> and <li> elements also. In my proof of concept I just used <div> elements. I also prefered using <h2>, <h3> and <time> tags instead of ordinary <p> tags.
You can play with my codepen here: https://codepen.io/patacra/pen/wvperjL
You can see it here after SCSS was compiled to CSS:
html, body {
margin: 0;
position: relative;
}
html {
background-color: #f6f6f6;
}
html::before {
content: "";
display: block;
position: absolute;
z-index: -1;
border-radius: 50%;
background-color: #ffebeb;
top: 8em;
right: -8em;
width: 15em;
height: 15em;
}
body {
padding: 1em;
font-family: Arial, sans serif;
font-size: 14px;
}
body::before, body::after {
content: "";
display: block;
position: absolute;
z-index: -1;
border-radius: 50%;
background-color: #ffebeb;
}
body::before {
top: -10em;
left: -15em;
width: 25em;
height: 30em;
}
body::after {
top: -12em;
right: -12em;
width: 25em;
height: 25em;
}
.timelines {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: flex-start;
}
.timeline-title {
font-size: 1em;
font-weight: bold;
}
.timeline-item {
margin-bottom: 2em;
}
.timeline-item h3 {
font-size: 1em;
font-weight: bold;
text-transform: uppercase;
margin: 0;
position: relative;
}
.timeline-item h3::before {
content: "";
position: absolute;
left: -2.35em;
background-color: #fe4747;
width: 0.7em;
height: 0.7em;
border-radius: 50%;
transform: translate(-0.5px, 0.2em);
}
.timeline-items {
margin: 2em;
padding: 0.01em 0 3em 2em;
border-left: 1px solid #fe4747;
}
.timeline-item {
margin-top: -0.3em;
}
.timeline-item time {
display: block;
float: left;
background-color: #ffebeb;
padding: 0.2em 0.4em;
}
.timeline-item > * {
margin: 1em 0;
}
.timeline-item .location {
clear: both;
font-size: 0.85em;
font-style: italic;
}
<div class="timelines">
<div class="timeline education">
<h2 class="timeline-title">Education</h2>
<div class="timeline-items">
<div class="timeline-item">
<h3>Master of Science in information systems with computing</h3>
<time datetime="2017/2019">2017 – 2019</time>
<div class="location">Dublin Business School, Dublin, Ireland</div>
</div>
<div class="timeline-item">
<h3>Bachelor of electrical engineering</h3>
<time datetime="2011/2016">2011 – 2016</time>
<div class="location">North Maharashtra University, Jalgaon, India</div>
</div>
<div class="timeline-item">
<h3>Boys town public school</h3>
<time datetime="2009/2010">2009 – 2010</time>
<div class="location">Dublin Business School, Dublin, Ireland</div>
</div>
</div>
</div>
<div class="timeline experience">
<h2 class="timeline-title">Experience</h2>
<div class="timeline-items">
<div class="timeline-item">
<h3>Sofware developer</h3>
<time datetime="2020/2022">2020 – Present</time>
<div class="location">Kare, Newbridge, Ireland</div>
</div>
<div class="timeline-item">
<h3>Junior developer</h3>
<time datetime="2019/2020">2017 – 2019</time>
<div class="location">Unipupil limited, Dublin, Ireland</div>
</div>
<div class="timeline-item">
<h3>Junior developer</h3>
<time datetime="2015/2017">2017 – 2019</time>
<div class="location">Dublin Business School, Dublin, Ireland</div>
</div>
</div>
</div>
</div>

"Button:active" moves all buttons instead of only clicked button

I know that it has something to do with margin's colliding or the layout but I can't figure it exactly out. My goal is to move a clicked (div) button by 5 pixels. The current way I do this is by setting the :active margin-top to 5.
I also can't figure out how to make all buttons take up the whole screen space. Using 100% or 100vh creates too much space.
CSS:
body{
margin: 0;
padding: 0;
font-family: Sans-Serif;
-webkit-animation: bgcolor 20s infinite;
animation: bgcolor 10s infinite;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}
header{
background-color: rgba(0, 0, 0, 0.5);
color: white;
text-align: center;
font-size: 25px;
}
.container{
padding: 10px;
margin: 0 auto;
text-align: center;
}
.question{
font-size: 35px;
margin: 10px;
font-weight: bold;
color: white;
}
.buttons-container{
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 10px;
height: 100%;
}
.button{
padding: 25px;
background-color: green;
color: white;
font-size: 25px;
box-shadow: 0px 5px 0px #504f4f;
}
.button:active{
box-shadow: none;
margin-top: 5px;
}
#keyframes bgcolor {
0% {
background-color: #45a3e5
}
30% {
background-color: #66bf39
}
60% {
background-color: #eb670f
}
90% {
background-color: #f35
}
100% {
background-color: #864cbf
}
}
HTML
<?php
include 'header.php';
?>
<div class="wrapper">
<header>
Quiz
</header>
<div class="container">
<div class="question">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<div class="buttons-container">
<div class="button">
Opt 1
</div>
<div class="button">
Opt 2
</div>
<div class="button">
Opt 3
</div>
<div class="button">
Opt 4
</div>
</div>
</div>
</div>
</body>
</html>
A little further explanation from my comment: when you use margins, you are actually going to influence the document flow and that is causing the entire page to reflow and relayout.
If you want to preserve document flow but nudge the button around, you should consider using relative positioning, i.e. position: relative; top: -5px;.
ps: The default is position: static.

Image overlay doesn't fit

I've a problem with image overlay.
Code is here: https://codepen.io/r-smal/pen/BOBdmX
<section class="team">
<h2 class="team__title">team</h2>
<div class="team__wrapper container__team ">
<div>
<div class="team__card ">
<div class="team__overlay"></div>
<img class="team__img" src="https://i.imgur.com/vWIuUtd.jpg" alt="mako">
</div>
<h3 class="team__description">lorem</h3>
<p class="team__span">ipsum</p>
</div>
<div>
<div class="team__card ">
<div class="team__overlay"></div>
<img class="team__img" src="https://i.imgur.com/vWIuUtd.jpg" alt="mako">
</div>
<h3 class="team__description">lorem</h3>
<p class="team__span">ipsum</p>
</div>
<div>
<div class="team__card ">
<div class="team__overlay"></div>
<img class="team__img" src="https://i.imgur.com/vWIuUtd.jpg" alt="mako">
</div>
<h3 class="team__description">lorem</h3>
<p class="team__span">ipsum</p>
</div>
</section>
.container__team {
max-width: 1700px;
margin: 0 auto;
}
.team {
&__title {
margin: 100px;
text-align: center;
font-size: 30px;
text-transform: uppercase;
position: relative;
&::after{
content: "";
position: absolute;
width: 85px;
border-bottom: solid 3px #5dc6e8;
left: 48.5%;
top: 50px;
}
}
&__wrapper {
display: grid;
grid-template-columns: 33.33% auto auto;
text-align: center
}
&__description {
margin: 50px 0 20px;
text-align: center;
font-size: 35px;
}
&__span{
font-size: 35px;
text-align: center;
}
&__card {
position: relative;
}
&__overlay {
position: absolute;
background: rgba(0,0,0,0.6);
width: 100%;
height: 100%;
display: none;
}
&__img{
}
}
.team__card:hover .team__overlay{
display: block;
transition: 0.3s;
}
As you can see on codepen overlay on top of image is bigger than my image and I can't figure out why. I made it 'fit" but I have to use static margins so in resoult in mobile version it doesn't look right.
And one last question how do I position ::after element center under my text that will stay here even in mobile?Without using static margin like in my code.

CSS animation needs correction

I would really appreciate your help if you could check below in the codepen my css animation.
I'm trying to make this work better. I want this underline to start from below the icon, not to be stuck to the window, but to have some space from right just under the first icon.
* {
box-sizing: border-box;
}
body {
font: 300 100% 'Helvetica Neue', Helvetica, Arial;
}
.container {
width: 100%;
margin: 0 auto;
}
ul li {
display: inline;
text-align: center;
}
a {
display: inline-block;
width: 25%;
padding: .75rem 0;
margin: 0;
text-decoration: none;
color: #333;
}
.two:hover ~ hr {
margin-left: 40%;
}
.one:hover ~ hr {
margin-left: 12.5%;
}
.three:hover ~ hr {
margin-left: 66%;
}
.four:hover ~ hr {
margin-left: 75%;
}
hr {
height: .25rem;
width: 20%;
margin: 0;
background: tomato;
border: none;
transition: .3s ease-in-out;
}
.home-content-1{background-color: #F7F8F9; text-align: center;padding:5em 0em 2em;}
.home-content-1 .row{margin-top: 2em;}
.home-content-1 h3{font-weight: 700;text-transform: uppercase;color: #646464;font-size: 1.3125em;}
.hc-icon{width: 150px;height: 150px;border-radius: 50%;margin: 0px auto 2.25em;}
.hc-icon img{padding-top: 30px;}
.hc-icon1{background: #b5d73c;}
.hc-icon2{background: #32aaeb;}
.hc-icon3{background: #ef3f54;}
.circles li { padding: 10px;}
hr {
height: .25rem;
width: 22%;
margin-left: 12.5%;
background: tomato;
border: none;
transition: .3s ease-in-out;
}
<div class="home-content-1">
<div class="container">
<h1>The Blabla Approach</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.</p>
<div class="row">
<div class="col span_1_of_4">
<ul class="circles">
<li class="one"><a href="#">
<div class="hc-icon hc-icon1"></div>
<h3>Demand Generation</h3></a></li>
<li class="two"><a href="#"><div class="hc-icon hc-icon1">
</div>
<h3>Demand Generation</h3></a>
</li>
<li class="three">
<a href="#">
<div class="hc-icon hc-icon1"></div>
<h3>Demand Generation</h3></a></li>
<hr />
</ul>
</div>
Please see all my code here -
http://codepen.io/anetk/pen/QyZLNb
Personally, I would do this. I eliminated all the title stuff to isolate what you're trying to do. I substituted your 'hr' element with a 'div'. Changing the div's relative position to the parent container feels a lot safer than changing margins on an 'hr' element that's sized to the body. This responsively sizes the 'highlight' div with the 'li' elements. You can adjust the 'circles' container's margins and widths to your liking.
HTML:
<ul class="circles">
<li class="one">
<a href="#">
<div class="hc-icon hc-icon1"></div>
<h3>Demand Generation</h3>
</a>
</li>
<li class="two">
<a href="#">
<div class="hc-icon hc-icon1"></div>
<h3>Demand Generation</h3></a>
</li>
<li class="three">
<a href="#">
<div class="hc-icon hc-icon1"></div>
<h3>Demand Generation</h3>
</a>
</li>
<div class="highlight"></div>
</ul>
CSS:
body {
font: 300 100% 'Helvetica Neue', Helvetica, Arial;
margin:0;
}
.circles {
display:inline-block;
width:80%;
margin:0 10%;
padding:0;
}
.circles li {
display:inline-block;
list-style-type:none;
text-align:center;
width:33%;
}
.highlight {
position:relative;
left:0;
height:5px;
width:33%;
background: tomato;
transition: .3s ease-in-out;
}
a {
display: inline-block;
width: 100%;
margin: 0;
text-decoration: none;
color: #333;
}
.two:hover ~ .highlight {
left: 33%;
}
.three:hover ~ .highlight {
left: 66%;
}
.circles h3{font-weight: 700;text-transform: uppercase;color: #646464;font-size: 1.3125em;}
.hc-icon{width: 150px;height: 150px;border-radius: 50%;margin: 0px auto 2.25em;}
.hc-icon1{background: #b5d73c;}
.hc-icon2{background: #32aaeb;}
.hc-icon3{background: #ef3f54;}
http://codepen.io/midgitsuu/pen/VeEKgQ
Easiest solution is to put a style on the <hr> to shift it's starting position.
css:
hr {
height: .25rem;
width: 20%;
margin-left: 12.5%;
background: tomato;
border: none;
transition: .3s ease-in-out;
}
The idea is to align the hr with the first circle. You want to use a % and not px so that the align will be responsive with the size of the window.
The change was from margin: 0; to margin-left: 12.5%;

Can I readjust Bootstrap Column spans without JS?

I know this is probably totally against the whole idea of the grid system and the responsiveness but let's just assume I want to do the following anyway:
I have the layout that you can see in the picture below.
The problem is initially the whole image+text part takes col-md-9 and the twitter feed takes col-md-2 span on a 1920x 1080 screen. However when displayed on a screen of smaller resolution like 1280x800, I can keep the SAME LAYOUT by changing the image+text part to take up col-md-5 span. So my question is, is it possible to change the element's col-md class using media queries ? I know CSS cannot touch an elements classes but I thought maybe bootstrap came along with a solution. Otherwise I know I can use JavaScript to get the window size and swap the classes.
Here is some code should you need. I didnt want to post any code that is not relevant but if you guys need the whole thing, I can set up a jsfiddle prob.
Thanks ! 1
HTML:
<div class="newsfeed">
<div class="container">
<div class="row">
<div class="col-md-11 mainfeed">
<div class="row top-buffer">
<div class="col-md-3">
<img src="images/chris.jpg" width="190px" />
</div>
<div class="col-md-9">
<h2 class="pullup">Some text here</h2>
<p id="bodypart">Some more text here </p>
</div>
</div>
<div class="row top-buffer topborder">
<div class="col-md-3">
<img src="images/city.jpg" width="190px" height="280px" />
</div>
<div class="col-md-9">
<h2 class="pullup">Text text text</h2>
<p id="bodypart">Text....</p>
</div>
</div>
<div class="row top-buffer topborder">
<div class="col-md-3">
<img src="images/alex.jpg" width="190px" height="280px" />
</div>
<div class="col-md-9">
<h2 class="pullup">Some news text </h2>
<p id="bodypart">xxxxxxxxxxx
</p>
</div>
</div>
</div>
<div class="col-md-1 pull-right">
<!-- Tweet RRS-->
<div class="tweets pull-right">
<a class="twitter-timeline" href="https://twitter.com/sinanspd" data-widget-id="540693554432323584"
width="380px" data-chrome="transparent noscrollbar">Tweets by #sinanspd</a>
<script>
!function(d,s,id){
var js,fjs=d.getElementsByTagName(s)[0],
p=/^http:/.test(d.location)?'http':'https';
if(!d.getElementById(id)){
js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}
}(document,"script","twitter-wjs");
</script>
</div>
</div>
</div>
</div>
</div>
Relevant CSS:
/* ----------COMMON STYLING ------ */
body{
background-color: black !important;
}
.container{
width: 100%;
}
.jumbotron{
height: 340px;
background-size: cover;
background-image: url("images/banner.jpg");
background-repeat: no-repeat;
background-position: center;
}
.nav li{
display: inline;
margin-right: 130px;
}
#nomarginleft{
margin-right: 0px;
}
.nav a{
font-family: "Crimson Text";
font-size: 28px;
font-weight: bold;
z-index: 2;
text-decoration: none !important;
}
.pull-left{
margin-left: -350px;
margin-top: -30px;
}
.pull-right{
margin-right: -300px;
margin-top: -30px;
}
.nav{
background-color: black;
width: 100%;
}
.fixed {
position: fixed;
top: 0px;
height: 50px;
z-index: 1;
background-color: black;
}
/*--------------------- HOME PAGE ---------------- */
#display{
width: 960px;
height: 420px;
overflow: hidden;
margin: 30px auto 0px auto;
border-radius: 4px;
background-color: white;
}
#display ul{
position: relative;
margin: 0;
padding: 0;
height: 960px;
width: 420px;
list-style: none;
}
#display ul li{
position: relative;
display: block;
float: left;
margin: 0;
padding: 0;
width: 960px;
height: 420px;
}
#head > p{
font-family: "Crimson Text";
font-size: 30px;
font-weight: bold;
}
#head{
margin-top: 30px;
margin-left: 220px;
}
.newsfeed{
width: 86%;
height: 800px;
margin-left: -160px;
}
.mainfeed{
margin-left: 130px;
}
.pullup{
margin-top: 0px;
}
.top-buffer{
margin-top: 20px;
}
.topborder{
border-top: 1px solid white;
}
.tweets{
background-color: rgba(247,12,12,0.3);
border: 1px solid white;
margin-left: 50px;
border-color: white;
}
#media (min-width: 1000px) and (max-width: 1300px){
.jumbotron{
height: 250px;
}
.nav li{
margin-right: 50px;
}
.nav a{
font-size: 25px;
}
.pull-left{
margin-left: -60px;
}
.pull-right{
margin-right: -40px;
}
#display{
width: 700px;
height: 350px;
}
#head > p{
font-size: 25px;
}
#head{
margin-top: 30px;
margin-left: 80px;
display: block;
}
.newsfeed{
width: 86%;
}
.newsfeed h2{
font-size: 20px;
}
.mainfeed{
margin-left: 230px;
}
.newsfeed h2, .newsfeed p{
margin-left: 0px;
}
.top-buffer{
width: 800px;
}
.newsfeed .pull-right{
margin-right: -120px;
}
.tweets{
margin-right: -500px;
}
}
Why don't you change your code like below
<div>
<div class="col-lg-9 col-md-5">
<h2 class="pullup">Text text text</h2>
<p id="bodypart">Text....</p>
</div>
<div class="col-lg-3 col-md-5">
<img src="images/alex.jpg" width="190px" height="280px" />
</div>
</div>
So now, on bigger screens the screen will we divided 9 cols and 3 cols, on smaller screen sizes it will be 5 cols each.
If you want to change the layout for smaller screen i.e. tablets and screen just user col-sm-xx and col-xm-xx respectively.

Resources