8
In mobile there is a very common component that is known as "Toast", but I kept thinking about how to adapt it only with HTML and CSS
Is there any way to do something like this "component" above just using CSS and HTML, without framework or other libraries?
I arrived at this model below, but I would like to make it functional like these alerts
of the kind "Toast" that we see mainly on Android...
How to make it go up and stand still, and then click on the X to close it?
.btn {
background-color: purple;
border-radius: .5em;
box-shadow: 0 .25em .5em 0 rgba(0, 0, 0, .25);
padding: 1em;
color: #fff;
text-transform: uppercase;
font-family: sans-serif;
font-weight: bold;
border: none;
cursor: pointer;
transition: background-color 250ms;
}
.btn:hover {
background-color: rgb(100, 0, 100);
}
.toast {
position: fixed;
display: flex;
bottom: 0;
left: 0;
width: 100%;
justify-content: space-between;
background-color: rgb(100, 0, 100);
font-family: sans-serif;
}
.toast p,
.toast a {
color: #fff;
margin: 0;
padding: 2em;
text-decoration: none;
}
<br>
<label class="btn" for="open">TOAST</label>
<br>
<div class="toast">
<p>
Lorem, ipsum dolor.
</p>
<a href="#">
X
</a>
</div>
So in this case it is necessary to use javascript to manipulate these events and make the change in CSS, I will make an example
– Tácio Brito
@Taciiobrito I know that with JS or jQuery is possible, but my intention is to only do with HTML and CSS
– hugocsl
Got it, the effect of going up and down is possible to do, but the click event is only possible with javascript
– Tácio Brito
Hugo my question has nothing to do with your :) Guy like I do to make these animations?
– LeAndrade
@Leandrade this particular example of the component I took from Quasar you can see here, just click on qq button: http://v0-13.quasar-framework.org/components/toast.html now to record the screen that was what I did using a simple program called Screentogif. I simply put to record this piece of screen and it saves as an animated gif https://www.screentogif.com/? l=pt_br
– hugocsl
Jóia man, it was a program just like it needed. Thanks Hugo!
– LeAndrade
@Leandrade this program is very light! Less than 3mb :D has helped me a lot and works super well. I just miss being able to draw on the screen, but I haven’t looked into it yet...
– hugocsl