I have a div container called wrapper2 that contains something like a chat. There are like 5 messages in div container called chatleft which contain pictures, the div wrapper2 is smaller than all the messages together.
That means I would need a time based automated animation that scrolls down the messages from top to bottom. Just like when the page opens, after 5 seconds the animation should start and need 10 seconds to scroll down to the last message at the bottom.
Do I need javascript for it, or is it possible to animate it in CSS, if I need to time the animation?
Can you help me to get it animated?
Here's the div wrapper2
#wrapper2 {
margin: 0;
padding: 40px;
float: left;
height: 740px;
width: 600px;
background-color: #fff;
border-top: 7px solid #000CFF;
border-left: 7px solid #000CFF;
border-right: 7px solid #000CFF;
bottom: 0px;
background-image:
url(https://cloud.githubusercontent.com/assets/398893/15136779/4e765036-1639-11e6-9201-67e728e86f39.jpg)
}
.chatleft:after {
content: '';
position: absolute;
left: 0;
top: 50%;
width: 0;
height: 0;
border: 24px solid transparent;
border-right-color: #ccc;
border-left: 0;
margin-top: -24px;
margin-left: -24px;
}
.chatleft:after {
content: '';
position: absolute;
left: 0;
top: 50%;
width: 0;
height: 0;
border: 24px solid transparent;
border-right-color: #ccc;
border-left: 0;
margin-top: -24px;
margin-left: -24px;
}
<div id="wrapper2">
</div>
<div class="chatleft">
<p>Hi, <br> here's the text:
</p>
</div>
<div class="chatleft">
<img src="../bilder/smartwatch.png">
</div>
<div class="chatleft">
<img src="../bilder/smartwatch.png">
</div>
<div class="chatleft">
<img src="../bilder/smartwatch.png">
</div>
<div class="chatleft">
<img src="../bilder/smartwatch.png">
</div>
</div>
I'm not aware of any way to do what you want with CSS.
I always use the scroll function in js
element.scroll(x-coord, y-coord)
More documentation here
You can pair that with ↓ to get what you want
setTimeout(
function(){
// do stuff (propably scroll in your case)
},
[time in miliseconds]
)
The JQuery library is really handy for animations too
$("html, body").animate({
scrollTop: "500px"
});
Related
I want to achieve this kind of Layout using Css Transform or gradient Background?(see image below). Right now im stuck with it using conic-gradient, i dont know how to put a gradient background on it.
see snippet below. run the code snippet as fullpage.
Thanks Guys.
//gol-bg
.my-bg-image {
background: url("https://via.placeholder.com/728x90.png?text=Background-image+Backgground-image+Background-image") 0 0 / cover no-repeat;
}
.gol-bg {
display: block;
height: 200px;
width: 700px;
position: relative;
background: conic-gradient(
transparent 136deg, transparent 0 140deg, yellow 140deg);
.my-content {
position: relative;
z-index: 1;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="bg-dark my-bg-image">
<div class="row no-gutters">
<div class="col-6">
<div class="gol-bg">
<div class="my-content">content</div>
</div>
</div>
</div>
</div>
I'm not sure if i understood your question correctly but
Yes, you can use multiple transforms
(Also, take a look at this:
https://bennettfeely.com/clippy/)
Here's an example:
div {
height: 100px;
width: 100px;
background: #000;
color: #fff;
margin: 5em auto; /* Just to center it a bit */
/* Transform part */
transform: scale(2) rotate(90deg);
}
<div>Hello World</div>
this may not be the answer you are looking for but you can do this too. CSS is capable of making all sorts of shapes.
.my-bg-image {
background: url("https://via.placeholder.com/728x90.png?text=Background-image+Backgground-image+Background-image") 0 0 / cover no-repeat;
}
.gol-bg {
display: block;
position: relative;
width: 250px;
height: 0px;
border-left: 50px solid red;
border-right: 50px solid red;
border-bottom: 100px solid red;
border-top: 100px solid red;
position: relative;
}
.gol-bg:after {
content: '';
position: absolute;
background: transparent linear-gradient(91deg, #02b3bc 0, #171c8f 100%) 0 0 no-repeat padding-box;
width: 0;
height: 0;
border-left: 250px solid transparent;
border-right: 100px solid transparent;
border-bottom: 100px solid red;
position: absolute;
content: "";
top: 0px;
left: -50px;
}
.gol-bg .my-content {
position: relative;
z-index: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="bg-dark my-bg-image">
<div class="row no-gutters">
<div class="col-6">
<div class="gol-bg">
<div class="my-content">content</div>
</div>
</div>
</div>
</div>
First of all, I know this question has been asked before. But I couldn't find the right solution for my case. That is why, I am posting it again.
So I am having a side bar
<div className="LeftMenu">
<div style={{position:relative"}}>
<div className= "icon-Back-office-icons_Logout1"}/>
<span className="tooltiptext">Name 1</span>
</div>
<div style={{position:relative"}}>
<div className= "icon-Back-office-icons_Logout2"}/>
<span className="tooltiptext">Name2</span>
</div>
</div>
.LeftMenu {
background-color: white; // box-shadow: 1px 2px 9px 0 rgba(92, 131, 205, 0.06);
display: flex;
align-items: center;
flex-direction: column;
padding-top: 24px;
padding-bottom: 25px;
height: 100%;
z-index: 100;
width: 100px;
position: fixed;
overflow-x: visible;
overflow-y:auto;
}
.tooltiptext:hover {
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
left: 110%;
}
.tooltiptext::after {
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
The leftmenu div contains many children div. On hovering each child element a tool tip is displayed. A vertical scroll must be displayed if the length of children div increases. Hence I have given overflow-y auto. But the tooltip must be visible, and it has to overflow the leftmenu. Hence, I am giving overflow-x as visible.
But this doesn't work as I thought.
https://jsfiddle.net/jcj7k6kp/ Here is a jsfiddle that demonstrates my issue.
I don't think it's possible with only css. So here is a possible javascript solution (maybe you'll need to tweak some stuff to have px perfect centring ...):
const tooltips = Array.from(document.querySelectorAll('.tooltip'));
function displayTooltip(e) {
let tooltip = e.target;
let title = tooltip.getAttribute('data-title');
let tooltiptext = document.getElementById('tooltiptext');
let rect = tooltip.getBoundingClientRect();
let tooltipMargin = 14;
tooltiptext.innerHTML = title;
tooltiptext.style.top = rect.y + 'px';
tooltiptext.style.left = rect.x + rect.width + tooltipMargin + 'px';
tooltiptext.style.display = 'block';
}
function hideTooltip() {
let tooltiptext = document.getElementById('tooltiptext');
tooltiptext.style.display = 'none';
}
tooltips.forEach(function(t) {
t.addEventListener('mouseover', displayTooltip);
t.addEventListener('mouseout', hideTooltip);
});
.content {
height: 400px;
}
.LeftMenu {
width: 200px;
background-color: white;
box-shadow: 1px 0 0 0 #ebedf8, -6px 0 30px 0 rgba(42, 34, 64, 0.1);
display: flex;
align-items: center;
flex-direction: column;
padding-top: 24px;
padding-bottom: 25px;
position: fixed;
height: 100px;
z-index: 100;
overflow-x: hidden;
overflow-y: auto;
}
/*overflow-x and overflow-y isn't working as expected*/
/*overflow-x must be visible since I need the tooltip to be visible*/
/*overflow-y must be auto since I need to have a fixed height div and content must be scrollable if it doesnt't fit inside the fixed height*/
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltiptext {
position: absolute;
display: none;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
z-index: 1000;
}
.tooltiptext::after {
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
<div class='tooltiptext' id='tooltiptext'>
</div>
<div class="LeftMenu">
<div class="tooltip" data-title="Tooltip text">
Hover over me
</div>
<div class="tooltip" data-title="Tooltip text 2">
Hover over me 2
</div>
<div class="tooltip" data-title="Tooltip text 3">
Hover over me 3
</div>
<div class="tooltip" data-title="Tooltip text 4">
Hover over me 4
</div>
<div class="tooltip" data-title="Tooltip text 5">
Hover over me 5
</div>
<div class="tooltip" data-title="Tooltip text 6">
Hover over me 6
</div>
<div class="tooltip" data-title="Tooltip text 7">
Hover over me 7
</div>
<div class="tooltip" data-title="Tooltip text 8">
Hover over me 8
</div>
</div>
and a jsfiddle
I'm trying to create a bar graph with HTML/CSS and I'm having trouble with CSS's scale property. Here's my code so far:
.main {
position: absolute;
top: 350px;
width: 80%;
height: 65%;
background-color: #1d1d1d;
border: 20px #3f3f3f solid;
left: 50%;
transform: translate(-50%, 0);
}
.bar {
position: relative;
display: inline-block;
width: 30px;
margin-left: 1.1%;
background-color: #38ff90;
border-top: 5px #1d6d41 solid;
border-left: 5px #1d6d41 solid;
border-right: 5px #1d6d41 solid;
transform-origin: bottom;
transform: scaleY(10);
}
.bar-height {
position: relative;
display: inline-block;
opacity: 0;
}
<div class="main">
<div style="height: 100%;" class="bar-height"></div>
<div style="height: <?php echo $height ?>px;" class="bar"> </div>
</div>
When I use scale(), this ends up scaling the border on each bar. How can I scale the bar element without scaling the border?
You've some examples here:
note that it's usually done with SCSS or JS /any JS framework.
https://codepen.io/Victa/pen/xDqbf
https://codepen.io/dxdc100xp/pen/WwMQwE
https://codepen.io/baletsa/pen/oHcfr
the code provided is only to see the logic and the procedure for reach this. SCSS is a good option and not too difficult to use it's like CSS on steroids.
I have problem with write code which will display presented situation as in the examples below. It is about triangles, they should contact one of the vertices (
not necessarily on half the page, it would be 60/40). While the triangles are not a big problem, that responsively is a challenge for me. On the background I would like put img (maybe like background-image, maybe like diferrent layer + mask with overlay: hidden).
Model 1:
Model 2:
What I was tray so far:
<style>
.section1::after {
width: 0;
height: 0;
right: -200px;
position: absolute;
top: 0;
z-index: -1;
border-style: solid;
border-width: 0 0 795px 750px;
border-color: transparent transparent #fddfc0 transparent;
}
.section1 .img-right {
position: absolute; right: 0; top: 0;
}
.section2 {
background-color: #fddfc0;
height: 670px;
background-image: url(../img2.png);
}
.section2 .trapezoid {
border-bottom: 670px solid white;
border-left: 714px solid transparent;
width: 100%;
position: absolute;
right: 0;
}
</style>
<div class="section1">
<div class="text">
text
</div>
<div class="img-right"><img src="img.png" alt="" /></div>
</div>
<div class="section2">
<div class="trapezoid">
text
</div>
</div>
As you see i tried two methods. Section1 with ::after pseudoelement which display triangle on the right and section2 where I put trapezoid on top which masks section2 div. As I said, my problem is how to make it responsive.
I am putting together a slideshow for a CMS, this slideshow has some tolerance for a range of image dimensions. Unfortunately I am unable to wrap all the images in a border.
See the image to better understand the problem.
Please check this, hope this will work for you.
.slider_container {
position: relative;
}
.slider_container img {
position: relative;
width: 100%;
}
.slider_container .border_box {
position: absolute;
border: 3px solid #fff;
left: 5px;
right: 5px;
top: 5px;
bottom: 10px;
}
<div class="slider_container">
<img src="http://www.electricprism.com/aeron/slideshow/images/1.jpg" alt="">
<div class="border_box"></div>
</div>