Anchor fails to activate in flexbox item - html

I have a flex container holding multiple items. I am setting the flex item class inside the anchor tag and trying to enable a link to work when a user clicks the anchored element.
The element is a 3 stage div... the first div is a circle with an icon, the "second" div (if you want to call it a second div...) loads the ::before psuedo element that loads some dimensionality to the circle. and the third div is a text item that appears when the item is hovered.
The issue is that when you hover over the element i am not able to click the follow on link. My guess is the anchor is being covered by the divs.
I have attempted setting z-index's across elements but cant seem to get the anchor to expose itself
HTML:
<div class="flex_row">
<a class="flex_col" src="http://www.cnn.com">
<div class="circle_shape">
<i class="fas fa-sitemap"></i>
<div class="circle_text">
<p>CNN IS A TERRIBLE NEW SOURCE!</p>
</div>
</div>
<div>
<h2>CNN SUCKS</h2>
</div>
</a>
</div>
CSS:
.flex_col{
flex: 1;
margin: 10px;
}
.circle_shape {
position: relative;
display: flex;
padding: 50% 0;
border-radius: 50%;
overflow: hidden;
border: 1px solid gray;
font-size: 16px;
font-family: 'Source Sans Pro', sans-serif;
justify-content: center;
align-items: center;
background: radial-gradient(circle at 50% 120%, #81e8f6, #76deef 10%, #055194 80%, #062745 100%);
}
.circle_shape:before {
content: "";
position: absolute;
top: 1%;
left: 5%;
width: 90%;
height: 90%;
border-radius: 50%;
background: radial-gradient(circle at 50% 0px, #ffffff, rgba(255, 255, 255, 0) 58%);
filter: blur(5px);
z-index: 2;
}
.circle_shape:hover{
box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1), 0 1px 2px rgba(0,0,0,0.1);
}
.circle_shape img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.circle_shape i{
position: absolute;
text-align: center;
font-size: 4vw;
text-shadow:
0 0 1px #fff,
0 1px 2px rgba(0,0,0,0.3);
}
.circle_shape h2 {
position: absolute;
bottom: 10%;
font-size: 1vw;
font-weight: 800;
text-align: center;
}
.circle_text{
position: absolute;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0,51,102, 0.9);
border-radius: 50%;
width: 100%;
height: 100%;
overflow: hidden;
opacity: 0;
transition: all 0.4s ease-in-out;
transform: scale(0);
}
.circle_text p {
color: #fff;
padding: 4px;
text-align: center;
font-size: calc(7px + .5vw);
text-shadow:
0 0 1px #fff,
0 1px 2px rgba(0,0,0,0.3);
}
.circle_shape:hover .circle_text{
transform: scale(1);
opacity: 1;
}
fiddle: https://jsfiddle.net/honeynutz/czq9y5fp/4/
I would expect the link in question to load cnn, but instead it does nothing.

The solution is actually very simple and I'm sure you'll kick yourself that you didn't spot it! I'm surprised it took me so long.
The issue is that you're using src on your anchor where you should be using href
More information on HTML Links

Related

Overlapping Divs, need them to be vertical on top of each other

I'm trying to stack the on top of each other vertically but they are overlapping for some reason and not sure if it has to do with the positioning. I'm not very good at CSS. Also, is there an easier way to align the datetime span to the right side instead of using padding-left: 1140px? Thank you
<div class="content-box">
<span class="name">John Doe</span>
<span class="datetime">May 2022</span><br><br>
<span class="content">Lorem ipsum</span>
</div>
<div class="content-box">
<span class="name">Jane Doe</span>
<span class="datetime">June 2022</span><br><br>
<span class="content">Lorem ipsum</span>
</div>
.content-box {
justify-content: center;
top: 600px;
position: absolute;
width: 75%;
border: none;
outline: none;
font-family: 'Roboto Mono', monospace;
font-size: 18px;
transform: translate(0);
background-image: linear-gradient(45deg, #4568DC, #B06AB3);
padding: 20px 40px;
border-radius: 5px;
box-shadow: 0 22px 44px rgba(128, 128, 128, 0.1);
transition: box-shadow .25s;
padding: 60px;
}
.content-box .name {
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: linear-gradient(45deg, #4568DC, #B06AB3);
font-size: 30px;
}
.content-box .content {
color: #4568DC;
font-size: 20px;
}
.content-box .datetime {
padding-left: 1140px;
color: black;
font-size: 18px;
}
.content-box .content {
color: #4568DC;
font-size: 20px;
}
.content-box:after {
content: '';
border-radius: 4px;
position: absolute;
margin: 1px;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: -1;
background: white;
}
.content-box:hover {
background-image: linear-gradient(-45deg, #00FFFF, #ff1a1a);
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
transition: .5s;
}
.content-box:hover .name {
background-image: linear-gradient(-45deg, #4568DC, #B06AB3);
}
The problem here is that both div has content-box class; this class applies position: absolute; , which is the main cause of overlapping. Removing this css property you should be able to se both div.
Regarding date time span you could change the class .content-box .datetime { color: black; font-size: 18px; } (you have to remove the padding)
And add the following properties to .content-box class to display datetime correctly without padding:
display: flex;
flex-flow: column;

CSS - Button border gradient [duplicate]

This question already has answers here:
Border Gradient with Border Radius
(2 answers)
Closed 1 year ago.
After searching extensively I am stuck on how I might go about replicating this button in CSS, specifically the border as I deed to use this on other elements if possible.
The Designed Button
button.rounded-button {
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 1.125rem 2rem;
position: absolute;
width: 13.5919rem;
height: 4.375rem;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(0.7942rem);
border-radius: 5.8652rem;
border-image-slice: 1 1 0 0;
border: 1px solid;
border-image-source: linear-gradient(257.34deg, #FFFFFF 4.56%, rgba(255, 255, 255, 0) 29.19%);
font-size: 1.25rem;
line-height: 2.125rem;
color: #fff;
}
body {
background: #393939;
}
<!-- SVG Not included with the example -->
<button type="button" class="rounded-button">
Watch video
<!-- <img src="/assets/img/glyphs/ic-play.svg" alt="Watch video"> -->
</button>
Ideally I am looking to have a class that I can apply to any element which adds the desired effect and that can be reversed, I have tried pseudo elements such as :after but to no joy
I really am not sure if this can be acvhieved in pure css 🤦🏻‍♂️
Consider using a ::before hidden behind. This is the closest I can make it without additional elements.
button.rounded-button {
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 1rem 2.25rem;
border-radius: 1000px;
border: none;
position: relative;
background: #343434;
font-size: 1.25rem;
line-height: 2rem;
color: #fff;
}
button.rounded-button::before {
content: '';
display: block;
position: absolute;
border-radius: 1000px;
top: -0.1em;
bottom: -0.1em;
right: -0.1em;
left: -0.1em;
z-index: -1;
background: linear-gradient(240deg, #ffffff 0%, #343434 25%);
}
body {
background: #1d1d1d;
padding: 2rem;
}
<button type="button" class="rounded-button">
Watch video
</button>
But it would be better to have a wrapper around the button as ::before with z-index: -1 is a bit of a hack.
Bonus
Then you can add some glass like effect to it.
button.rounded-button {
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 1rem 2.25rem;
border-radius: 1000px;
border: none;
position: relative;
background: #343434;
font-size: 1.25rem;
line-height: 2rem;
color: #fff;
cursor: pointer;
}
button.rounded-button::before {
content: '';
display: block;
position: absolute;
border-radius: 1000px;
top: -0.1em;
bottom: -0.1em;
right: -0.1em;
left: -0.1em;
z-index: -1;
background: linear-gradient(240deg, #343434 0%, #ffffff 20%, #343434 50%);
background-size: 140%;
background-position: 0 0;
transition: background .3s;
}
button.rounded-button:hover::before {
background-position: 100% 0;
}
body {
background: #1d1d1d;
padding: 2rem;
}
<button type="button" class="rounded-button">
Watch video
</button>
You can use box-shadow to apply a border effect on just the right side:
box-shadow: 5px 0 1px -2px grey;
.rounded-button {
box-shadow: 5px 0 1px -2px grey;
}
/* YOUR INITIAL CODE */
button.rounded-button {
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 1.125rem 2rem;
position: absolute;
width: 13.5919rem;
height: 4.375rem;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(0.7942rem);
border-radius: 5.8652rem;
border-image-slice: 1 1 0 0;
border: 1px solid;
border-image-source: linear-gradient(257.34deg, #FFFFFF 4.56%, rgba(255, 255, 255, 0) 29.19%);
font-size: 1.25rem;
line-height: 2.125rem;
color: #fff;
}
body {
background: #393939;
}
<button type="button" class="rounded-button">
Watch video
</button>

How to overlay transparent text on an image with a dark overlay background on hover?

Title is a bit of a mouthful. I've just started with CSS and am trying to achieve the effect a text overlay while the image is still transparent behind the text.
Below is what I've managed to achieve by snipping together various bits of code I've found. I am struggling to get the dark overlay the same size as the image. I haven't used any margin or padding on the overlay or image so have no clue why it's happening. I've also tried several ways to align the text so it sits vertically in the middle but have had no such luck.
.image-container {
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
}
.border {
border-radius: 50%;
}
.image-container .after {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
display: none;
color: #FFF;
border-radius: 50%;
}
.image-container:hover .after {
display: block;
background: rgba(0, 0, 0, .6);
border-radius: 50%;
}
#title {
background: url('https://bopepor.es/wp-content/uploads/2018/08/Logo-200x200PX.png');
background-size: cover;
color: #fff;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
padding: 0;
display: flex;
}
h1 {
font-size: 80px;
font-family: sans-serif;
text-align: center;
text-shadow: 0 0 1px rgba(0, 0, 0, .1);
margin: 0;
padding: 0;
letter-spacing: -1px;
line-height: 0.8;
}
<div class="image-container">
<img src="https://bopepor.es/wp-content/uploads/2018/08/Logo-200x200PX.png" class='border' />
<div class="after">
<div id="title">
<h1><b>ONE<br>TWO</b></h1>
</div>
</div>
</div>
For the first issue You will not able to center the overlay on to the image because the image isn't actually 200px x 200px because there are transparent pixels around the image. so first crop the transparent pixels around the image and get it's real size. Then replace the 200px size in the css below to the appropriate size.
I have corrected your code snippet to be able to center the text by adding display: flex and align-content: center (for vertical alignment) and justify-content: center(for horizontal alignment),
I have also added overflow: hidden to the .image-container .after to prevent overflowed text and changed the text size to 60px for better visibility.
.image-container {
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
}
.image-container .after {
position: absolute;
display: none;
left: 0;
bottom: 0;
overflow: hidden;
color: #FFF;
}
.image-container:hover .after {
display: flex;
background: rgba(0, 0, 0, 0.6);
border-radius: 50%;
border-width: 0px;
width: 200px;
height: 200px;
}
#title {
background: url('https://bopepor.es/wp-content/uploads/2018/08/Logo-200x200PX.png');
background-size: cover;
color: #fff;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
padding: 0;
display: flex;
align-content: center;
justify-content: center;
width: 100%;
}
h1 {
font-size: 60px;
font-family: sans-serif;
text-align: center;
text-shadow: 0 0 1px rgba(0, 0, 0, .1);
margin: 0;
padding: 0;
display: flex;
align-items: center;
letter-spacing: -1px;
line-height: 0.8;
}
<div class="image-container">
<img src="https://bopepor.es/wp-content/uploads/2018/08/Logo-200x200PX.png" class='border' />
<div class="after">
<div id="title">
<h1><b>ONE<br>TWO</b></h1>
</div>
</div>
</div>

Pictures side by side with text

i would like to create something like this: example.
Its my code.
HTML:
<td>
<a href="/Topicality/Detail/1030" class="topicality-list-match-image">
<img src="/Content/Images/test.jpg" alt="brak obrazka" class="topicality-image-match-single-image" data-detailid="1030">
<img src="/Content/Images/blankshield.png" alt="brak obrazka" class="topicality-image-match-single-image" data-detailid="1030">
<div class="topicality-text-on-images">
2:5
</div>
</a>
</td>
CSS:
.topicality-list-match-image {
height: 80px;
max-width: 110px;
display: inline-flex;
white-space: nowrap;
filter: brightness(100%);
}
.topicality-image-match-single-image {
width: 100%;
object-fit: cover;
overflow: hidden;
}
.topicality-text-on-images {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #30D5C8;
font-weight: bold;
font-size: xx-large;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
It works on firefox, but when i use different browser it looks ugly.
example on edge
It looks that the text is in the center of whole table and pictures are wider.
Instead of using td I would suggest using div with display:flex
.flex-row {
display: flex;
flex-flow: row nowrap;
height: 100vh;
background: #000;
}
.flex-column {
display: flex;
flex-flow: column nowrap;
}
.flexitem {
text-align: center;
color: white;
font: normal normal bold 2em/1 Helvetica;
box-sizing: border-box;
flex: 1;
}
.flexitem .flexitem {
font-size: 1em;
}
.imageright {
background: url(https://images.unsplash.com/photo-1463062511209-f7aa591fa72f?dpr=1&auto=format&fit=crop&w=568&h=379&q=60&cs=tinysrgb);
background-size: cover;
opacity: 0.8;
}
.imageleft {
background: url(https://images.unsplash.com/photo-1451976426598-a7593bd6d0b2?dpr=1&auto=format&fit=crop&w=568&h=379&q=60&cs=tinysrgb);
background-size: cover;
opacity: 0.8;
}
.overlay-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #30D5C8;
font-weight: bold;
font-size: xx-large;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
z-index:99;
}
<div class="flex-row">
<div class="overlay-text">2:5</div>
<div class="flex-column flexitem">
<div class="flexitem imageleft"></div>
</div>
<div class="flexitem imageright"></div>
</div>
It will also be responsive too.
Give the style position: relative for the class .topicality-list-match-image, to let the div get placed with respect to the correct relative position.
.topicality-list-match-image {
height: 80px;
max-width: 110px;
display: inline-flex;
white-space: nowrap;
filter: brightness(100%);
position: relative; /*add this style*/
}

Vertically Align <a> text inside a div

I am having trouble vertically aligning the 's text inside a div.
This is what I have. I need to center "Next" inside the blue box:
#import url(http://fonts.googleapis.com/css?family=Muli);
/*Makes the little side arrow*/
.open {
position: fixed;
width: 100px;
height: 40px;
left: 50%;
top: -1000px;
margin-left: -80px;
margin-top: -30px;
border: 1px solid #ccc;
background-color: #fff;
border-radius: 6px;
padding: 10px 30px;
color: #444;
transition: all ease-out 0.6s;
}
.open:hover {
border: 1px solid #aaa;
box-shadow: 0 0 8px #ccc inset;
transition: all ease-out 0.6s;
}
.tutorial-box {
position: fixed;
width: 400px;
height: 238px;
top: 75px;
background-color: #F3F3F3;
border-radius: 6px;
box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.4);
}
.slider-turn p, .tutorial-box h1{
margin-left: 10px;
}
.tutorial-box:before {
content: '';
position: absolute;
left: -14px;
top: 28px;
border-style: solid;
border-width: 10px 14px 10px 0;
border-color: rgba(0, 0, 0, 0) #f3f3f3 rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
}
.tutorial-box p {
width: 350px;
font-size: 16px;
color: #a8aab2;
font-weight: 400;
line-height: 28px;
float: left;
margin: 0;
}
.tutorial-box .bottom {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
width: 100%;
bottom: 0;
position: absolute;
}
.tutorial-box .bottom .btn-2 {
flex: 3;
-webkit-flex: 3;
-ms-flex: 3;
width: 100%;
height: 54px;
background-color: #373942;
border-bottom-left-radius: 6px;
display: flex;
}
.tutorial-box .bottom span {
flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
line-height: 54px;
color: #fff;
margin-left: 25px;
font-size: 18px;
}
.next {
text-decoration: none;
display: inline-block;
vertical-align: middle;
text-align: center;
flex: 1;
background-color: #6cb5f3;
border: 0;
margin: 0;
padding: 0;
text-transform: uppercase;
color: #fff;
font-weight: bold;
border-bottom-right-radius: 6px;
cursor: pointer;
transition: all .3s;
}
.next:hover {
text-decoration: none;
background-color: #6BA5D6;
transition: all .3s;
}
.next:active {
text-decoration: none;
background-color: #5F8AAF;
}
.slider-tutorial-box {
width: 350px;
margin: 0 25px;
overflow: hidden;
}
.slider-turn {
width: 10000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- TUTORIAL -->
<div class="tutorial-box">
<h1>Welcome</h1>
<span class="close"></span>
<div class="slider-container">
<div class="slider-turn">
<p>
Here, under the Company tab, is where you will do most of the company managment.<br>
</p>
</div>
</div>
<div class="bottom">
<div class="btn-2">
<span>Step 2/?</span>
</div>
Next
</div>
</div>
Please let me know how I can center the text vertically to the center of the div.
Thank you very much. Let me know if I wasn't clear enough.
Seems like you already did that for .tutorial-box .bottom span so, do the same thing for .next
.next{
line-height: 54px;
}
the simplest and possibly most easy way would be to add the 'center' and '/center' tag before and after the text you want, and after each letter use '/br' to move to the next line. this will add some bulk, but would be considerably easier than other methods.
<center>
'letter'</br>'next letter'</br>'next letter'</br>
</center>
repeating the letter and break for all letters
alternatively, you could also add "div" tags around the "a" tag. you would have to modify the 'height' and 'width' to make it vertical for you. I would use px for this and not '%' or 'em'. add this to them:
<div style="height: /* modify this */100px; width: /* and this*/20px;">
Next
</div>
this may not be AS compatible cross platform though.
Like this:
.next {
position: relative;
top: 50%;
transform: translateY(-50%);
}
A nice trick that works both vertically and horizontally.