CSS arrow on tooltip DIV - css

I'm trying to add a centered arrow/triangle on each side of a rectangular tooltip div and I've tried applying some code from other questions and demos, but none look centered or the arrow's shadow overlaps the div. The arrow should be white with a shadow of 0 0 20px 0 rgba(0, 0, 0, 0.2);.
HTML:
<div class="tooltip cal-tooltip">
<div class="tooltip cal-tooltip">
<div class="cal-tooltip-cont">
<div class="cal-tooltip-img four-three-img">
<img src="http://placeholdit.imgix.net/~text?txtsize=75&txt=Event%20Photo&w=600&h=400" />
</div>
<div class="card-info">
<h2>Wrapping related content title</h2>
<h3>Event date</h3>
<h3>Event venue</h3>
</div>
</div>
</div>
CSS:
.tooltip {
position: absolute;
top: 0;
z-index: 1;
background-color: white;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2);
}
.tooltip > div {
padding: 15px;
}
.tooltip > div img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.cal-tooltip {
width: 20em;
cursor: auto;
}
.cal-tooltip .cal-tooltip-cont {
display: flex;
}
.cal-tooltip .cal-tooltip-cont > div {
flex-basis: 50%;
}
.cal-tooltip .cal-tooltip-cont > div:nth-child(1) {
padding-right: 5px;
}
.cal-tooltip .cal-tooltip-cont > div:nth-child(2) {
padding-left: 5px;
}
.cal-tooltip .cal-tooltip-cont > div h2 {
padding-bottom: 5px;
font-size: 1em;
}
.cal-tooltip .cal-tooltip-cont > div h3 {
font-size: .85em;
}
Demo: http://codepen.io/ourcore/pen/Lxeapj

Try something like this:
.tooltip {
position: absolute;
top: 20px;
left: 60px;
z-index: 1;
background-color: #fff;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, .2);
width: 17em;
padding: 15px;
}
.tooltip:after {
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -1em;
margin-top: -1em;
left: 100%; /* change to 0% for left arrow */
top: 50%;
box-sizing: border-box;
border: 1em solid black;
border-color: transparent transparent #fff #fff;
transform-origin: 50% 50%;
transform: rotate(-135deg); /* change to 45 deg for left arrow */
box-shadow: -5px 5px 10px 0 rgba(0, 0, 0, 0.1);
}
.card {
display: flex;
}
.card img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.card > div {
flex-basis: 50%;
}
.card-info {
padding-left: 15px;
}
<div class="tooltip">
<div class="card">
<div class="card-image">
<img src="http://placeholdit.imgix.net/~text?txtsize=75&txt=Event%20Photo&w=600&h=400" />
</div>
<div class="card-info">
<h2>Test title</h2>
<h3>Event date</h3>
<h3>Event venue</h3>
</div>
</div>
</div>
Inspired by this: https://codepen.io/ryanmcnz/pen/JDLhu
It's a start at least. Hope it helps!

Related

CSS | why does the linear gradient do have slides when the direction is set top/bottom? [duplicate]

This question already has answers here:
How to remove the stripes that appears when using linear gradient property [duplicate]
(2 answers)
Closed 1 year ago.
why does the linear gradient do have slides when the direction is set top/bottom ? if i set it to right or left it doesn't show slides .. should i set the width to 100% ? or make it auto .. the problem here is that when i tried to use the "deg" instead of using to bottom the code didn't run
here is the codepen
<body>
<header>
<div class="header-logo">ON ANIME</div>
<div class="header-links">
<ul>
<li>url</li>
<li>url</li>
<li>url</li>
</ul>
</div>
<div class="search-bar"><button>Buy now</button></div>
</header>
<div class="container">
<div class="item">
<img src="https://fr.techtribune.net/wp-content/uploads/2021/01/boruto-chapter-55.jpg"/>
<span class="caption">Text below the image</span>
</div>
</div>
<script src="" async defer></script>
</body>
* {
outline: 0px;
box-sizing: border-box;
position: relative;
padding: 0;
margin: 0;
}
body {
/* background-image:
url('https://www.teahub.io/photos/full/34-345522_all-anime-characters-wallpaper-hd.jpg');
background-size: cover; */
/* background-image:
linear-gradient(-90deg, rgba(
145, 146, 122, 0.62), rgba(
217, 91, 132, 0.58)), url(
'https://www.teahub.io/photos/full/34-345522_all-anime-characters-wallpaper-hd.jpg'); */
background: linear-gradient(to bottom, rgba(0, 0, 255, 0.548), rgba(255, 192, 203, 0.555)),
url(https://www.teahub.io/photos/full/34-345522_all-anime-characters-wallpaper-hd.jpg)
;
background-size: cover;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgb(22, 22, 48);
width: 100%;
height: 65px;
z-index: 9999;
box-shadow: 0 0 20px #00000094;
}
.header-links ul li a {
text-decoration: none;
}
.header-links ul li {
display: inline;
margin-right: 50px;
}
.header-logo {
padding: 20px;
margin-left: 50px;
}
.search-bar {
padding: 20px;
margin-right: 50px;
}
.container {
width: 93%;
max-width: 1600px;
margin: 0 auto;
background-color: rgba(77, 77, 201, 0.781);
}
div.item {
vertical-align: top;
display: inline-block;
text-align: center;
width: 270px;
margin: 0 12px 30px;
box-shadow: 0 0 16px black;
transition: transform .5s ease;
}
img {
padding: 0;
display: block;
width: 100%;
height: 100%;
border-top-left-radius: 3%;
border-top-right-radius: 3%;
}
.caption {
padding: 0;
display: block;
background-color: #232223;
}
div.item:hover {
transform: scale(1.05);
}
Add this to your css. The height of your html and body is not getting the whole height of the page size.
html,body {
height: 100%
}
you can also try different options to set the height.
html,body{
height: 100vh;
}

Position Element in front of another object Using CSS

I'm new in CSS and this time I want to position my object in front of slider, So I read about that and I know Slider should have position: relative and my other object with position: absolute
Desire result:
So I do it, but it does not work, also the object is not responsive, how can I fix that? I prepare an example of how it works.
#main-slider {
width: 100%;
height: 528px;
/* border-radius: 0% 0% 50% 50% / 0% 0% 20% 20%; */
border-bottom-right-radius: 50% 25%;
border-bottom-left-radius: 50% 25%;
position: relative;
}
.badge {
background-color: #fff;
border-radius: 30px;
box-shadow: 0 15px 35px 0 rgba(42,51,83,.12), 0 5px 15px rgba(0,0,0,.06);
width: 17%;
position: absolute;
}
.text {
padding: 0.5rem 0.25rem 0.5rem 1rem;
}
.link {
border-radius: inherit;
display: inline-block;
background-color: red;
padding: 0.5rem 1rem;
color: #F9F9EC;
width: 57%;
}
<section>
<div>
<img id="main-slider" src="https://via.placeholder.com/1365x528?text=Slider">
<div class="badge">
<span class="text">Contact us</span>
<a class="link">
(555) <strong>123 4567</strong>
</a>
</div>
</div>
</section>
Regards
You can do this adding a class called .wrapper to this and using display: flex and justify content center. Also need a margin top: 0.5em to your .badge
Read more about flex boxes here
Run snippet below.
#main-slider {
width: 100%;
height: 528px;
/* border-radius: 0% 0% 50% 50% / 0% 0% 20% 20%; */
border-bottom-right-radius: 50% 25%;
border-bottom-left-radius: 50% 25%;
position: relative;
}
.badge {
background-color: #fff;
border-radius: 30px;
box-shadow: 0 15px 35px 0 rgba(42, 51, 83, .12), 0 5px 15px rgba(0, 0, 0, .06);
position: absolute;
margin-top: 0.5em;
}
.text {}
.link {
border-radius: inherit;
display: inline-block;
background-color: red;
padding: 0.5rem 1rem;
color: #F9F9EC;
}
.wrapper {
display: flex;
justify-content: center;
align-items: flex-end;
}
<section>
<div class="wrapper">
<img id="main-slider" src="https://via.placeholder.com/1365x528?text=Slider">
<div class="badge">
<span class="text">Contact us</span>
<a class="link">(555) <strong>123 4567</strong></a>
</div>
</div>
</section>

mobile optimization CSS

So I am just starting out in FE and found a really cool parralex animation via CSS that I have applied to my site.
I am happy with the desktop, but on mobile I lose the text boxes for some of the slides.
I tried to add the #media to specify changes for mobile screen sizes, and it works ok on Pixel 3, but on Iphone it is still cutting off. I suspect it is something to do with the overflow - but I cannot seem to fix it. I have tried a couple if things, I am not starting to think I just need to do a mobile style sheet. As I am new to the game I thought I would post on here to see if there is a quick fix!
Thanks,
D
<html>
<head>
<title></title>
<style>
html {
height: 100%;
overflow: hidden;
}
body {
margin:0;
padding:0;
perspective: 1px;
transform-style: preserve-3d;
height: 100%;
overflow-y: scroll;
overflow-x: hidden;
font-family: 'Lora', serif;
}
h1 {
font-size: 250%
}
p {
font-size: 140%;
line-height: 150%;
color: #333;
}
.slide {
position: relative;
padding: 25vh 10%;
min-height: 100vh;
width: 100vw;
box-sizing: border-box;
box-shadow: 0 -1px 10px rgba(0, 0, 0, .7);
transform-style: inherit;
color: #fff;
text-shadow: 0 5px 5px #808080;
}
img {
position: absolute;
top: 50%;
left: 35%;
width: 320px;
height: 240px;
transform: translateZ(.25px) scale(.75) translateX(-94%) translateY(-100%) rotate(2deg);
padding: 10px;
border-radius: 5px;
background: rgba(240,230,220, .7);
box-shadow: 0 0 8px rgba(0, 0, 0, .7);
}
img:last-of-type {
transform: translateZ(.4px) scale(.6) translateX(-104%) translateY(-40%) rotate(-5deg);
}
.slide:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
box-shadow: 0 0 8px 1px rgba(0, 0, 0, .7);
}
.title {
width: 50%;
padding: 3%;
border-radius: 5px;
background: rgba(240,230,220, .7);
box-shadow: 0 0 8px rgba(0, 0, 0, .7);
}
.slide:nth-child(2n) .title {
margin-left: 0;
margin-right: auto;
}
.slide:nth-child(2n+1) .title {
margin-left: auto;
margin-right: 0;
}
.slide, .slide:before {
background: 50% 50% / cover;
}
.header {
text-align: center;
font-size: 175%;
color: #fff;
text-shadow: 0 5px 5px #008000;
}
#title {
background-image: url("code1.jpg");
z-index:2;
}
#title h1 {
transform: translateZ(.25px) scale(.75);
transform-origin: 50% 100%;
color: #fff;
text-shadow: 0 5px 5px #008000;
}
#slide1:before {
background-image: url("code2.jpg");
transform: translateZ(-1px) scale(2);
}
#slide2 {
background-image: url("code3.jpg");
z-index:2;
}
#slide3:before {
background-image: url("dark.jpg");
transform: translateZ(-1px) scale(2);
}
#slide4 {
background: #222;
}
#media screen and (max-width: 1020px) {
#title, #slide1, #slide2, #slide3, #slide4 {
float: none;
width: auto;
overflow-y: scroll;
overflow-x: scroll;
}
}
</style>
</head>
<body>
<div id="title" class="slide header">
<h1>
</h1>
</div>
<div id="slide1" class="slide">
<div class="title">
<h1>About me</h1>
<p></p>
</div>
</div>
<div id="slide2" class="slide">
<div class="title">
<h1>Skill set</h1>
<p></p>
</div>
<img src="code1.jpg">
<img src="hype.jpg">
</div>
<div id="slide3" class="slide">
<div class="title">
<h1>Why choose me?</h1>
<p></p>
</div>
</div>
<div id="slide4" class="slide header">
<h1></h1>
<p></p>
</div>
</body>
</html>
You can set z-index for the title, and remember to set position to z-index work well
#media screen and (max-width: 1020px) {
.slide .title {
position: relative;
z-index: 5;
}
}

div height automatically changing causing error with styling

I'm having a problem with span where it is changing the height of my div, breaking the styling I have implemented.
I have four images stacked 2 by 2 and I want text to roll up when I hover over them.
However, when I hover over them and the text appears it changes the size of the div since I have translated the text up by a certain amount.
I have made the divs blue so you can better see what is happening.
The divs obtain their height automatically. There are no set pixel heights in my website; everything is made using percentages so it would seem I can't just hide overflow.
Any help would be much appreciated on how I can fix this.
/* CSS Document */
body {
padding-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
background-image: url("images/background/space2.jpg");
background-size: cover;
margin: 0px;
}
#navigation {
width: 17%;
height: 100%;
position: fixed;
z-index: 3;
margin-left: 8%;
background-color: black;
opacity: 0.8;
filter: alpha(opacity=80);
float: left;
}
.navigationbody {
width: 100%;
height: 50px;
border-bottom: 2px rgba(255, 255, 255, 0.1) solid;
text-align: center;
}
.navigationbody a {
text-decoration: none;
color: white;
font-size: 30px;
position: relative;
top: 15%;
}
.navigationbody a:hover {
opacity: 0.8;
filter: alpha(opacity=80);
}
#navcontent {
height: auto;
margin-top: 50%;
position: static;
background-color: ;
align-items: center;
align-content: center;
}
#icon {
width: 100%;
margin-bottom: 10px;
background-color: ;
margin-left: 15%;
}
#bodycontainer {
bottom: 200px;
}
#icon img {
width: 70%;
height: auto;
}
#container {
width: 100%;
position: fixed;
top: 0px;
bottom: 0px;
}
#contentcontainer {
width: 75%;
margin-left: 25%;
height: 100%;
z-index: 2;
float: left;
overflow-y: auto;
}
#contentcontainer:hover {
background-color: rgba(0, 0, 0, 0.3);
}
#content {
padding: 0px;
}
.about {
width: auto;
margin-top: 10%;
margin-bottom: 30%;
margin-left: 20%;
margin-right: 20%;
text-align: center;
padding-bottom: 20px;
border-bottom: dotted 2px rgba(255, 255, 255, 1.00);
}
.about a {
color: white;
font-size: 20px;
background-color: rgba(0, 0, 0, 0.20);
}
.about h1 {
color: white;
border-bottom: dotted 2px rgba(255, 255, 255, 1.00);
}
.about h2 {
color: white;
}
.abouthome {
width: auto;
margin-top: 10%;
margin-bottom: 30%;
margin-left: 20%;
margin-right: 20%;
text-align: center;
padding-bottom: 20px;
}
.abouthome h2 {
color: white;
border-bottom: dotted 2px rgba(255, 255, 255, 1.00);
}
.abouthome a {
color: white;
font-size: 20px;
background-color: rgba(0, 0, 0, 0.20);
}
.software {
width: 100%;
margin-top: 60px;
align-content: center;
background-color: ;
}
.software img {
width: 100px;
height: auto;
}
.software img:hover {
opacity: .5;
}
.gallery {
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 180px;
}
.gallery:hover {
border: 1px solid #777;
}
.gallery img {
width: 100%;
height: auto;
}
.desc {
padding: 15px;
text-align: center;
}
#contentgames {
right: 0px;
padding-left: 10%;
padding-top: 20%;
}
.games {
width: 45%;
height: auto;
overflow: hidden;
margin-right: 20px;
float: left;
transition: 0.5s;
position: relative;
background-color: aqua;
word-break: keep-all;
}
.games:hover {}
.games span {
color: white;
position: relative;
left: 10px;
bottom: 20px;
margin: 10px;
padding: 5px;
font-size: 0px;
opacity: 0;
transition: 0.5s;
align-content: center;
}
.games:hover span {
color: white;
position: relative;
bottom: 200px;
margin: 10px;
font-size: 18px;
opacity: 1;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Steven game design</title>
<link rel="stylesheet" type="text/css" href="style3.css" />
</head>
<div id="navigation">
<div id="navcontent">
<div id="icon">
<img src="http://placehold.it/150x150">
</div>
<div id="bodycontainer">
<div class="navigationbody"></div>
<div class="navigationbody">
Home
</div>
<div class="navigationbody">
About
</div>
<div class="navigationbody">
Blog
</div>
<div class="navigationbody">
Videos
</div>
<div class="navigationbody">
Pictures
</div>
<div class="navigationbody">
Contact
</div>
</div>
</div>
</div>
<body>
<div id="container">
<div id="contentcontainer">
<div id="contentgames">
<div class="games">
<img src="http://placehold.it/350x150" width="100%" height="auto" />
<span> This is a simple game I started making in flash. All of the artwork was created in flash. Unfortunately I never completed the game many things don't work such as the score, taking damage, boss and many more
</span>
</div>
<div class="games">
<img src="http://placehold.it/350x150" width="100%" height="auto" />
<span> This is a simple game I made in flash it took less than a week to create.</span>
</div>
<div class="games">
<img src="http://placehold.it/350x150" width="100%" height="auto" />
<span> This is another simple game in flash I made over the course of a few days.</span>
</div>
<div class="games">
<img src="http://placehold.it/350x150" width="100%" height="auto" />
<span>This is the game I am currently working on. It is my first 3d game. I am making it in the unreal engine 4.</span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
If the goal is for the image to be the deciding factor for the position and size of the div and the elements within it, this minimal, responsive example should provide some examples:
https://jsfiddle.net/d7aab2x7/2/
The critical code sets the text block to be positioned absolutely, allow the div to constrain it's size around the image:
div {
border: 1px solid red;
display: inline-block;
width: 40%;
position: relative;
overflow: hidden;
}
img {
display: block;
width: 100%;
}
span {
position: absolute;
bottom: -50px;
background: green;
height: 50px;
transition: bottom 200ms ease-out;
}
For this HTML:
<div>
<img src="http://placehold.it/300x300" />
<span>Some text that will appear on hover of the image</span>
</div>
Please note: I have re-created using the simplest example possible, and my fiddle uses only CSS for animation. Hopefully this provides you with an answer, while also providing general usefulness to the next person searching for something like this.

How create this effect 3D with CSS3

The effect I'm trying to make is as in this image:
http://i271.photobucket.com/albums/jj146/cosmossx/footer.jpg
I've made some progress as you can see in this FIDDLE
css:
.final{ background:#000;
width:100%;}
.triangle {
border-color: white black black black;
border-style: solid;
border-width: 15px 25px 25px 25px;
height: 0px;
width: 500px;
margin: 0 auto;
}
.triangle2 {
border-color: black white white white;
border-style: solid;
border-width: 15px 25px 25px 25px;
height: 0px;
width: 500px;
margin: 0 auto;
}
HTML:
<div class="final"> <div class="triangle"></div>
<br>
<br>
<br>
<br>
<br><br>
<br>
<br>
</div>
<div class="triangle2"></div>
My question is: what would be the best way to make it?
Thanks.
Best approach would be using css transform function and pseudo-elements
DEMO
Source (using Sass and Autoprefixer for brevity):
<footer class="footer">
<div class="footer__main">
<div class="footer__inner">
<div class="footer__content">
<!-- content goes here -->
</div>
</div>
</div>
<div class="footer__bottom"></div>
</footer>
.footer {
height: 500px;
}
.footer__main {
height: 80%;
background: #eee;
}
.footer__bottom {
height: 20%;
background: darken(#eee, 20);
}
.footer__inner {
background: white;
max-width: 800px;
margin: 0 auto;
height: 100%;
padding: 0 20px;
position: relative;
}
.footer__content {
background: #eee;
height: 100%;
transform: translateY(20px);
position: relative;
&:before,
&:after {
content: "";
background: darken(#eee, 10);
width: 20px;
height: 100%;
position: absolute;
top: 0; bottom: 0;
z-index: 2;
}
&:before {
right: 100%;
transform-origin: 100%;
transform: skewY(45deg);
}
&:after {
transform-origin: 0;
left: 100%;
transform: skewY(-45deg);
}
}

Resources