I'm creating a custom Elementor widget in WordPress using a custom plugin, my problem is that when I add the widget to my page it overflows it's container.
See problem here
My php/html code:
<div id='video-wrapper'>
<video id='custom-video' autoplay muted loop video-url='<?php echo(esc_url( $settings['video']['url'])); ?>' timebar='<?php echo $timebar ?>' volume='<?php echo $volume ?>'>
<source src="<?php echo(esc_url( $settings['video-background']['url'])); ?>" type="video/mp4">
<source src="<?php echo(esc_url( $settings['video-background']['url'])); ?>" type="video/ogg">
<source src="<?php echo(esc_url( $settings['video-background']['url'])); ?>" type="video/mvk">
Your browser does not support the video tag.
</video>
<div id='timebar'></div>
<div id='custom-video-volume-wrapper'>
<svg viewBox="0 0 154 234" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.6392 172.687H52.1515L134.313 231.478C142.337 237.219 153.492 231.483 153.492 221.616V12.1476C153.492 2.24405 142.264 -3.48304 134.249 2.33204L53.8752 60.6426H11.6392C5.21104 60.6426 0 65.8544 0 72.2836V161.046C0 167.475 5.21104 172.687 11.6392 172.687ZM130.092 34.2078L67.8952 78.8923V155.444L130.092 199.607V34.2078ZM45.1018 83.9246H23.7633V149.89H45.1018V83.9246Z"/>
</svg>
<input id='custom-video-volume' type='range' min='0' max='100' step='1' value='50'></input>
</div>
<div id='custom-video-popup'>
<span>Seu vídeo já começou</span>
<svg viewBox="0 0 250 234" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.6392 172.687H52.1515L134.313 231.478C142.337 237.219 153.492 231.483 153.492 221.616V12.1476C153.492 2.24406 142.264 -3.48304 134.249 2.33204L53.8752 60.6426H11.6392C5.21104 60.6426 0 65.8544 0 72.2836V161.046C0 167.475 5.21104 172.687 11.6392 172.687ZM130.092 34.2078L67.8952 78.8924V155.444L130.092 199.607V34.2078ZM45.1018 83.9246H23.7633V149.89H45.1018V83.9246ZM246.591 86.3641C251.136 90.9102 251.136 98.2809 246.591 102.827L232.391 117.029L246.591 131.23C251.136 135.777 251.136 143.147 246.591 147.693C242.046 152.239 234.676 152.239 230.131 147.693L215.931 133.492L201.732 147.693C197.186 152.239 189.817 152.239 185.271 147.693C180.726 143.147 180.726 135.777 185.271 131.23L199.471 117.029L185.271 102.827C180.726 98.2809 180.726 90.9102 185.271 86.3641C189.817 81.818 197.186 81.818 201.732 86.3641L215.931 100.566L230.131 86.3641C234.676 81.818 242.046 81.818 246.591 86.3641Z" fill="black"/>
</svg>
<span>Clique para ouvir</span>
</div>
</div>
/* VOLUME */
#custom-video-volume-wrapper {
position: absolute;
bottom: 1rem;
right: 1rem;
display: none;
align-items: center;
justify-content: center;
flex-direction: row;
}
#custom-video-volume-wrapper.active {
display: flex;
}
#custom-video-volume-wrapper svg {
width: 1rem;
height: 1rem;
margin-right: .25rem;
fill: crimson;
}
input[type=range] {
-webkit-appearance: none;
background-color: silver;
width: 8rem;
height: .5rem;
border-radius: .25rem;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
background-color: crimson;
width: 1rem;
height: 1rem;
border-radius: 50%;
cursor: pointer;
}
/* TIMEBAR */
#timebar {
width: 100%;
max-width: 0%;
height: .5rem;
background-color: crimson;
animation-duration: 30s;
animation-fill-mode: forwards;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
#timebar.animate {
animation-name: grow;
}
#timebar.pause {
animation-play-state: paused;
}
/* VIDEO */
video {
width: 100%;
cursor: pointer;
}
#video-wrapper {
position: absolute;
display: flex;
align-items: flex-start;
justify-content: center;
flex-direction: column;
position: absolute;
width: 100%;
/*min-height: 15rem*/
}
/* POPUP */
#custom-video-popup {
position: absolute;
top: calc(50% - 5rem);
left: calc(50% - 7rem);
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
width: 14rem;
height: 10rem;
border-radius: 2rem;
color: #000;
background-color: crimson;
opacity: .75;
cursor: pointer;
transition: transform .3s ease;
}
#custom-video-popup.deactivated {
display: none;
}
#custom-video-popup:hover {
transform: scale(1.05);
}
#custom-video-popup span {
color: #000;
font-family: 'Roboto', sans-serif;
font-size: 1rem;
font-weight: bold;
}
#custom-video-popup svg {
width: 3rem;
margin: 1rem 0;
}
#keyframes grow {
0% {
max-width: 0%;
}
30% {
max-width: 50%;
}
70% {
max-width: 75%;
}
100% {
max-width: 100%;
}
}
#keyframes grow2 {
0% {
max-width: 0%;
}
30% {
max-width: 50%;
}
70% {
max-width: 75%;
}
100% {
max-width: 100%;
}
}
I've tried to add a wrapper with a display: block;, but it didn't help much. I would like to keep the display: flex; to my items. I was expecting that the container would not overflow, but automatically resize the containers height.
Any idea on what could be causing this problem?
Have you tried adding a wrapper with a position:relative; and a width of 100%?
I hope this helps!
Related
I have images in a file with its name in the database. And I would like to display it in a responsive list. But I would like to add for each image an icon in a corner (or text below the frame) of the image to remove it if necessary. here is my html and php code
<?php
$sqlimage = "SELECT * FROM images where `id_user` = '".$customer_id."'";
$result = mysqli_query($conn, $sqlimage);
foreach ($result as $imageShow) {
?>
<div class="container">
<h1>Image Galerry</h1>
<div class="image-container">
<div class="image">
<img src="<?php echo 'Media/'.$imageShow['file_name'] ?>" alt="">
<div>
<i class='fa fa-trash' style='color: red'></i>
</div>
</div>
<div class="linkDelete"
style="font-size: 13px;position:absolute;text-align:center; width:26px; padding-top:3px">
Delete
</div>
<?php
}
mysqli_close($conn);
?>
</div>
<div class="popup-image">
<span>×</span>
<img src="Media/3-20220714-68033.jpg" alt="">
</div>
</div>
And here is my CSS3 code to display the images
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container{
position: relative;
min-height: 100vh;
background-color: #191C24 !important;
}
.container h1{
font-size: 40px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-weight: normal;
padding: 15px;
color: #333;
text-align: center;
text-transform: capitalize;
}
.container .image-container{
display: flex;
flex-wrap: wrap;
gap:15px;
justify-content: center;
padding: 10px;
}
.container .image-container .image{
height: 250px;
width: 350px;
border: 10px solid #fff;
box-shadow: 0 5px 15px rgba(0, 0, 0, .1);
overflow: hidden;
cursor: pointer;
float: left;
}
.linkDelete{
float: left;
clear: left;
}
.container .image-container .image img{
height: 100%;
width: 100%;
object-fit: cover;
transition: .2s linear;
}
.container .image-container .image a{
height: 100%;
width: 100%;
object-fit: cover;
transition: .2s linear;
}
.container .image-container .image:hover img{
transform: scale(1.1);
}
.container .popup-image{
position: fixed;
top: 50px;
left: 0px;
background: rgba(0, 0, 0, .9) ;
height: 100%;
width: 100%;
z-index: 100%;
display: none;
}
.photo-name{
position: absolute;
width: 100%;
bottom: 30px;
text-align: center;
background-color: cyan;
}
/* .image-container{
position:relative;
}
.image-container a{
position:absolute;
bottom:0px;
right:0px;
} */
.container .popup-image span{
position: absolute;
top: 0;
right: 10px;
font-size: 60px;
font-weight: bolder;
color: #fff;
cursor: pointer;
z-index: 100;
}
.container .popup-image img{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border: 5px solid #333;
border-radius: 5px;
width: 75%;
object-fit: cover;
}
#media (max-width:768px){
.container .popup-image img{
width: 95%;
}
}
I would like to have an image and on this image there is the icon which tells me the link to delete which is already prepared
I tried several ways but each time I find the icon in a position since the images with different dimensions.
If there was a possibility if not below the image a link to delete it and thank you in advance.
Set position: relative; on .image. Then set a class on the parent div for the icon. I called it .icon-wrapper. Set this parent to position: absolute; with top: 0;. Then you can use width and height: 100%; so it falls directly on top of your .image div.
Then you can use display: flex; with align-items: center; and justify-content: center; on .icon.wrapper to align the icon vertically and horizontally.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
position: relative;
min-height: 100vh;
background-color: #191C24 !important;
}
.container h1 {
font-size: 40px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-weight: normal;
padding: 15px;
color: #333;
text-align: center;
text-transform: capitalize;
}
.container .image-container {
display: flex;
flex-wrap: wrap;
gap: 15px;
justify-content: center;
padding: 10px;
}
.container .image-container .image {
height: 250px;
width: 350px;
border: 10px solid #fff;
box-shadow: 0 5px 15px rgba(0, 0, 0, .1);
overflow: hidden;
cursor: pointer;
float: left;
}
.linkDelete {
float: left;
clear: left;
}
.container .image-container .image img {
height: 100%;
width: 100%;
object-fit: cover;
transition: .2s linear;
}
.container .image-container .image a {
height: 100%;
width: 100%;
object-fit: cover;
transition: .2s linear;
}
.container .image-container .image:hover img {
transform: scale(1.1);
}
.container .popup-image {
position: fixed;
top: 50px;
left: 0px;
background: rgba(0, 0, 0, .9);
height: 100%;
width: 100%;
z-index: 100%;
display: none;
}
.photo-name {
position: absolute;
width: 100%;
bottom: 30px;
text-align: center;
background-color: cyan;
}
/* .image-container{
position:relative;
}
.image-container a{
position:absolute;
bottom:0px;
right:0px;
} */
.container .popup-image span {
position: absolute;
top: 0;
right: 10px;
font-size: 60px;
font-weight: bolder;
color: #fff;
cursor: pointer;
z-index: 100;
}
.container .popup-image img {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border: 5px solid #333;
border-radius: 5px;
width: 75%;
object-fit: cover;
}
#media (max-width:768px) {
.container .popup-image img {
width: 95%;
}
}
i {
font-size: 3em;
color: red;
}
.image {
position: relative;
}
.icon-wrapper {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
display: flex;
align-items: center;
justify-content: center;
}
<script src="https://kit.fontawesome.com/6140596fcb.js" crossorigin="anonymous"></script>
<div class="container">
<h1>Image Galerry</h1>
<div class="image-container">
<div class="image">
<img src="https://dummyimage.com/300/000/fff" alt="">
<div class="icon-wrapper">
<i class="fa-solid fa-trash"></i>
</div>
</div>
<div class="linkDelete" style="font-size: 13px;position:absolute;text-align:center; width:26px; padding-top:3px">
Delete
</div>
</div>
<div class="popup-image">
<span>×</span>
<img src="Media/3-20220714-68033.jpg" alt="">
</div>
</div>
Thanks for adding the delete icon. But this one blocked me from displaying the full size image when I click inside the photo (the popup-image class action).
In the CSS
.container .popup-image img{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border: 5px solid #333;
border-radius: 5px;
width: 75%;
object-fit: cover;
}
#media (max-width:768px){
.container .popup-image img{
width: 95%;
}
}
And in the HTML
<div class="popup-image">
<span>×</span>
<img src="Media/3-20220714-68033.jpg" alt="">
</div>
This is what I've got but this doesn't solve the problem for different devices and screen sizes.
<html>
<body>
<iframe src="FILE LINK" width="1920" height="1080"></iframe>
</body>
</html>
How do I make it full screen? I've tried width: 100%; height: 100%
For reaching fullscreen in this case you need to use height: 100vh;, width: 100%;
body {
margin: 0;
}
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.landing {
width: 100%;
height: 100vh;
}
.image-list {
margin: 0;
padding: 0;
list-style: none;
width: 100%;
height: 100vh;
border: 6px solid #00f;
overflow: hidden;
}
.image-list .image {
border: 6px solid #f00;
width: 100%;
height: 400px;
background-size: cover;
background-position: center center;
height: 100vh;
}
.centered-element {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
background: #fff;
padding: 1rem;
width: 280px;
}
.centered-element ul {
margin: 0;
padding: 0;
list-style: none;
}
.centered-element ul span {
opacity: 0.4;
}
<!-- body -->
<section class='landing'>
<ul class='image-list'>
<li class='image'
style='background-image: url(https://unsplash.it/1600/1600)'>
</li>
<li class='image'
style='background-image: url(https://unsplash.it/1600/1800)'>
</li>
<li class='image'
style='background-image: url(https://unsplash.it/1600/1700)'>
</li>
</ul>
</section>
<!-- /body -->
Well, a simple snippet like the following one did the trick for me:
body {
height: 100%;
width: 100%;
margin: 0;
padding: 5px;
box-sizing: border-box;
}
html {
height: 100%;
}
<iframe src="#" width="100%" height="100%"></iframe>
Just play with the containers.
You should of course set your own container sizes to 100% and not html and body.
What happens is that I have a website on android that loads me correctly, on the desktop as well. But on iphone or mac os, I have problems and that is that it has many defects that is to say that it does not catch the styles.
I leave you part of the html and the css that I use in addition to the bootstrap 4 library.
They can also be viewed on my host to verify the problem of the iphone because at first glance on the desktop it looks normal, the problem is on an Apple device.
https://arstrikestudio.com/dlx/
HTML.
<div class="delexlp">
<span class="ir-arriba"> <i class="fa fa-arrow-circle-down"></i></span>
<div id="logo-div" class="paddingleft">
<div id="logo-img">
<img id="lgefect" src="delexni/img/default/delex2020-01.svg" width="100%" height="100%">
</div>
</div>
<div class="imgscroll">
</div>
<div class="col-lg-12 col-sm-12 oculto">
<div class="row">
<div class="col-lg-6 col-sm-12">
<div class="d-none d-md-block sectlp">
<img src="delexni/img/default/delex.svg" alt="">
<br>
<div class="container">
<p class="text-center">Facilitamos a nuestros clientes el proceso<br>de comprar por internet brindandoles un servicio<br><span style="background-color:orange;color:white;"> SIMPLE, CONFIABLE Y RAPIDO </span><br>ganandonos su confianza libra por libra.</p>
</div>
<br>
<div class="text-center">
<a class="btn btn-secondary" href="register">CREA TU CUENTA</a>
<a class="btn btn-secondary" href="login">INICIA SESION</a>
</div>
</div>
<div class="sectlpm d-md-none">
<div class="row spaceblank2" style="padding-left:18%">
<img src="delexni/img/default/delex.svg" alt="" width="300px" height="200px">
</div>
<div class="row" style="padding-top:40vh">
<div class="container">
<p class="text-center spaceblank">Facilitamos a nuestros clientes el proceso<br>de comprar por internet brindandoles un servicio<br><span style="background-color:orange;color:white;"> SIMPLE, CONFIABLE Y RAPIDO </span><br>ganandonos su confianza libra por libra.</p>
</div>
</div>
<div class="row" style="padding-left:15%">
<div class="text-center">
<a class="btn btn-secondary" href="register">CREA TU CUENTA</a>
<a class="btn btn-secondary" href="login">INICIA SESION</a>
</div>
</div>
</div>
</div>
<div class="d-none d-md-block col-lg-6">
<img src="delexni/img/default/delex-x.svg" alt="">
</div>
</div>
</div>
</div>
CSS.
body{
background-size: cover;
background-repeat: no-repeat;
}
.delexlp{
background: url('../img/default/fondo2.svg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.delexlg{
background: url('../img/default/fondo.svg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 100vh;
}
#logo-div {
position: fixed;
height: 14vh !important;
width: 100vw;
}
#logo-div img{
width: 100%;
height: 100%;
background-size: cover;
}
.black{
width: 100vw;
height: 45px;
background: black;
}
.oculto{
display: none;
}
.imgscroll{
height: 6000px;
}
.textground{
font-size: 720px;
}
.ir-arriba {
display:block;
text-align: center;
padding:20px;
font-size:48px;
color:#fff;
cursor:pointer;
position: fixed;
bottom:20px;
right:50%;
margin: auto;
z-index: 6;
}
.btn-delex{
background-color: #f6871f;
color: white;
}
.btn-delex2{
background-color: #f6871f;
color: white;
}
#keyframes crescendo {
0% {transform: scale(1);}
100% {transform: scale(43);}
}
.paddingleft{
padding-left: 0 !important;
}
.sectlp {
padding: 15%;
}
.pdtop15{
padding-top: 15%;
}
#media (max-width: 700px) {
.form-control{ background-color: red; }
}
h1, h2, h3, h4, h5 ,h6{
font-weight: 200;
}
a{
text-decoration: none;
}
p, li, a{
font-size: 14px;
}
fieldset{
margin: 0;
padding: 0;
border: none;
}
/* GRID */
.twelve { width: 100%; }
.eleven { width: 91.53%; }
.ten { width: 83.06%; }
.nine { width: 74.6%; }
.eight { width: 66.13%; }
.seven { width: 57.66%; }
.six { width: 49.2%; }
.five { width: 40.73%; }
.four { width: 32.26%; }
.three { width: 23.8%; }
.two { width: 15.33%; }
.one { width: 6.866%; }
/* COLUMNS */
.col {
display: block;
float:left;
margin: 0 0 0 1.6%;
}
.col:first-of-type {
margin-left: 0;
}
.row{
padding: 20px 0;
}
/* CLEARFIX */
.cf:before,
.cf:after {
content: " ";
display: table;
}
.cf:after {
clear: both;
}
.cf {
*zoom: 1;
}
.wrapper{
width: 100%;
margin: 30px 0;
}
/* STEPS */
.steps{
list-style-type: none;
margin: 0;
padding: 0;
/*background-color: #fff;*/
text-align: center;
}
.steps li{
display: inline-block;
margin: 20px;
color: #ccc;
padding-bottom: 5px;
}
.steps li.is-active{
border-bottom: 1px solid #3498db;
color: #3498db;
}
/* FORM */
.form-wrapper .section{
padding: 0px 20px 30px 20px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background-color: #fff;
opacity: 0;
-webkit-transform: scale(1, 0);
-ms-transform: scale(1, 0);
-o-transform: scale(1, 0);
transform: scale(1, 0);
-webkit-transform-origin: top center;
-moz-transform-origin: top center;
-ms-transform-origin: top center;
-o-transform-origin: top center;
transform-origin: top center;
-webkit-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
text-align: center;
width: 100%;
}
.form-wrapper .section h3{
margin-bottom: 30px;
}
.form-wrapper .section.is-active{
opacity: 1;
-webkit-transform: scale(1, 1);
-ms-transform: scale(1, 1);
-o-transform: scale(1, 1);
transform: scale(1, 1);
}
.form-wrapper .button, .form-wrapper .submit{
background-color: #3498db;
display: inline-block;
padding: 8px 30px;
color: #fff;
cursor: pointer;
font-size: 14px !important;
font-family: 'Open Sans', sans-serif !important;
position: absolute;
right: 20px;
bottom: 20px;
}
.form-wrapper .submit{
border: none;
outline: none;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.form-wrapper input[type="text"],
.form-wrapper input[type="password"],.form-wrapper input[type="email"],.form-wrapper input[type="number"]
,.form-wrapper select,.form-wrapper textarea{
display: block;
padding: 10px;
margin: 10px auto;
background-color: #f1f1f1;
border: none;
width: 50%;
outline: none;
font-size: 14px !important;
font-family: 'Open Sans', sans-serif !important;
}
.form-wrapper input[type="radio"]{
display: none;
}
.form-wrapper input[type="radio"] + label{
display: block;
border: 1px solid #ccc;
width: 100%;
max-width: 100%;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
cursor: pointer;
position: relative;
}
.form-wrapper input[type="radio"] + label:before{
content: "✔";
position: absolute;
right: -10px;
top: -10px;
width: 30px;
height: 30px;
line-height: 30px;
border-radius: 100%;
background-color: #3498db;
color: #fff;
display: none;
}
.form-wrapper input[type="radio"]:checked + label:before{
display: block;
}
.form-wrapper input[type="radio"] + label h4{
margin: 15px;
color: #ccc;
}
.form-wrapper input[type="radio"]:checked + label{
border: 1px solid #3498db;
}
.form-wrapper input[type="radio"]:checked + label h4{
color: #3498db;
}
.spaceblank{
background-color: white;
opacity: 0.89;
}
.spaceblank2{
background-color: white;
}
.pd30{
padding-top: 30%;
}
.pd60{
padding-top: 60%;
}
.pd200{
padding-top: 200%;
}
/* tabletas */
#media (min-width: 768px) {
}
/* escritorio normales */
#media (min-width: 992px) {
{ font-size:px; }
}
/* pantallas grandes */
#media (min-width: 1200px) {
}
/*****/
#media screen and (min-width: 700px) {
.form-control { font-size: px; }
.form-wrapper .section{
position: absolute;
min-height: 30px;
}
}
#media screen and (min-device-width: 481px) and (max-device-width: 768px) {
.form-control { font-size: px; }
}
#media only screen and (max-device-width: 480px) {
.form-control { font-size: 30px; }
.form-wrapper input[type="text"],
.form-wrapper input[type="password"],.form-wrapper input[type="email"],.form-wrapper input[type="number"]
,.form-wrapper select,.form-wrapper textarea{
width: 100%;
outline: none;
font-size: 32px !important;
}
.form-wrapper .button{font-size: 32px !important;}
.ocultar{
display: none !important;
}
.form-wrapper .section{
min-height: 30px;
max-height: 100px
}
}
Well, the mobile version in all devices had problems in zoom, and I will explain how I fixed it.
First, when you transform: scale(); an element, if the width/height of the zoom rate are the same, you can provide only 1 parameter instead of 2 (as in original code). Also, doing it using jQuery.scroll() is really slow on some devices.
But you were indeed spot on in your code when you created a scale in the style attribute of the element, instead of an animation. If you do an animation, it gets a blurred zoom effect on desktop, inclusive. Also, putting the pictures embedded on a svg indeed made better optimization than converting the images to png (really!).
Putting the animation on the style, only iOS makes some blurriness, which I failed to remove.
So the main point of the answer is the css rule transform-origin.
Since each mobile device has a different screen size, simply zooming on center of image (which is the default behavior without transform-origin), makes the image zoom on the wrong spot.
SO, I got a specific coordinate of a working device which transform-origin worked, and applied a calculation to get the corresponding coordinates on each device (for instance, calculated using the document.documentElement.clientHeight for height). And then setting these coordinates on transform-origin it worked.
Also second important point: for the animation to behave performant on mobile, I've used requestAnimationFrame.
There is an important detail: you were totally correct in making a svg with black background and transparent letters. I've fiddled A LOT and the final answer made use of that, but I've trimmed the logo as I asked you, and made black borders calculated in css using calc(), to fill entire screen on mobile.
And finally, I've removed all superfluous paddings and applied flexbox on elements to get control of centering things vertically/horizontally.
You can see all my edits on https://github.com/niloct/delex_refactor, and I've published it using the awesome https://fast.io free hosting service integrated with github (on https://delex.imfast.io/).
Let me know if you have more questions. Thanks for reading.
I have a little problem.I'm still, learn to program and I don't have very good knowledge.
I'm trying to make view like this:
In this view items are located very evenly.
In my view items are not looking good:
Why i have to repair in my code to look like this online shop view?
My code is here:
<?php foreach($posts as $post) : ?>
<div class="col-xs-12 col-sm-6 col-md-4">
<h3><?php echo $post['title']; ?></h3>
<?php if($this->session->userdata('logged_in')) :?>
<small class="post-date">Posted on: <?php echo $post['created_at']; ?> in <strong><?php echo $post['name']; ?></strong></small>
<?php endif ?>
<div class="zoom-in">
<img class="post-thumb" src="<?php echo site_url(); ?>assets/images/posts/<?php echo $post['post_image']; ?>">
</div>
<?php echo word_limiter($post['body'],10); ?>
<b></b>
<input type="button" class="btn btn-danger addcart" productid="<?php echo $post['id'] ?>" value="Добави в количката">
<p><a class="btn btn-link" href="<?php echo site_url('/posts/'.$post['slug']); ?>">Read more</a></p>
</div>
<?php endforeach; } ?>
Thank you in advance!
resize Image Like this
html, body {
color: #333;
font-size: 16px;
line-height: 20px;
}
body {
margin: 20px;
}
h1 {
line-height: 1.2;
margin-bottom: 35px;
text-align: center;
}
h2 {
text-align: center;
}
img {
height: auto;
max-width: 100%;
}
.image-grid {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin: 0 auto 35px;
max-width: 920px;
}
.svg-image-grid {
clear: both;
margin: 0 auto 35px;
max-width: 920px;
overflow: hidden;
position: relative;
}
/** Screen readers only class from Bootstrap */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
overflow: hidden;
clip: rect(0,0,0,0);
white-space: nowrap;
clip-path: inset(50%);
border: 0;
}
/** Actual code examples */
/** Background */
.image-bg {
background-position: center center;
background-size: cover;
-webkit-flex: 0 0 auto;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
margin: 5px;
width: calc(25% - 10px);
}
.image-bg-placeholder {
height: 100%;
visibility: hidden;
width: 100%;
}
/** Object-fit */
.image-fit {
-webkit-flex: 0 0 auto;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
margin: 5px;
position: relative;
width: calc(25% - 10px);
}
.image-fit-placeholder {
height: 100%;
visibility: hidden;
width: 100%;
}
.image-fit-img {
bottom: 0;
height: 100%;
left: 0;
object-fit: cover;
object-position: center;
position: absolute;
right: 0;
top: 0;
width: 100%;
}
/** Absolute positioning */
.image {
-webkit-flex: 0 0 auto;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
margin: 5px;
overflow: hidden;
position: relative;
width: calc(25% - 10px);
}
.image-placeholder {
height: 100%;
visibility: hidden;
width: 100%;
}
.image-img {
left: 50%;
max-height: 150%;
max-width: 177%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
/** SVG */
.image-svg {
float: left;
margin: 5px;
padding-bottom: calc(25% - 10px);
position: relative;
width: calc(25% - 10px);
}
.image-svg svg {
bottom: 0;
display: block;
height: 100%;
left: 0;
position: absolute;
right: 0;
top: 0;
width: 100%;
}
/** Responsive grid */
#media (max-width: 480px) {
.image,
.image-fit,
.image-bg,
.image-svg {
width: calc(50% - 10px);
}
.image-svg {
padding-bottom: calc(50% - 10px);
}
}
<h1>Techniques to crop and resize images with CSS</h1>
<h2>Image as a background</h2>
<div class="image-grid">
<a href="https://www.flickr.com/photos/teroauralinna/33704491300" class="image-bg" style="background-image:url(https://farm3.staticflickr.com/2809/33704491300_1df01dd919_z_d.jpg)" target="_blank">
<img class="image-bg-placeholder" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" alt="" />
<img class="image-bg-img sr-only" src="https://farm3.staticflickr.com/2809/33704491300_1df01dd919_z_d.jpg" alt="Cropped image as a background example" />
</a>
<a href="https://www.flickr.com/photos/teroauralinna/33704488370" class="image-bg" style="background-image:url(https://farm3.staticflickr.com/2848/33704488370_9572b9d270_z_d.jpg)" target="_blank">
<img class="image-bg-placeholder" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" alt="" />
<img class="image-bg-img sr-only" src="https://farm3.staticflickr.com/2848/33704488370_9572b9d270_z_d.jpg" alt="Cropped image as a background example" />
</a>
<a href="https://www.flickr.com/photos/teroauralinna/34088934825" class="image-bg" style="background-image:url(https://farm4.staticflickr.com/3947/34088934825_0acfe80a04_z_d.jpg)" target="_blank">
<img class="image-bg-placeholder" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" alt="" />
<img class="image-bg-img sr-only" src="https://farm4.staticflickr.com/3947/34088934825_0acfe80a04_z_d.jpg" alt="Cropped image as a background example" />
</a>
<a href="https://www.flickr.com/photos/teroauralinna/34088930595" class="image-bg" style="background-image:url(https://farm4.staticflickr.com/3956/34088930595_2b84cec168_z_d.jpg)" target="_blank">
<img class="image-bg-placeholder" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" alt="" />
<img class="image-bg-img sr-only" src="https://farm4.staticflickr.com/3956/34088930595_2b84cec168_z_d.jpg" alt="Cropped image as a background example" />
</a>
</div>
I have a tooltip in my project.
What I like to do is add active button to my tooltip.
Problem is that the tooltip is displaying a HTML tags not a button...
Here is the effect of my work:-)
enter image description here
Bellow is my code.
Please if some one can help. Thank You.
/* Frame */
.frame {
height: 150px;
max-width: 1170px;
/*line-height: 130px;*/
/* overflow:visible !important;*/
}
.frame ul {
list-style: none;
margin: 0;
padding: 0;
height: 100%;
font-size: 14px;
}
.frame ul li {
float: left;
width: 232px;
height: 100%;
margin: 0 2px 0 0;
padding: 0;
background: #f1f1f1;
color: #00b5f6;
text-align: center;
cursor: default;
display:flex;
}
.frame ul li:hover{
color: #fff;
background: #00b5f6;
}
/* setup tooltips */
.tooltip {
position: relative;
z-index:1;
}
li .tooltip{
overflow:visible;
}
.tooltip:before,
.tooltip:after {
position:absolute;
display:inline-block;
opacity: 0;
pointer-events: none;
width:225px;
}
.tooltip:after {
border-right: 6px solid transparent;
border-top: 6px solid #00b5f6;
border-left: 6px solid transparent;
content: '';
height: 0;
top: -5px;
left: 20px;
width: 0;
display:none;
}
.tooltip:before {
background: #00b5f6;
border-radius: 2px;
color: #fff;
content: attr(data-title);
font-size: 12px;
padding: 6px 10px;
top: 0px;
left: 0px;
white-space: nowrap;
height:118px;
max-width:212px !important;
display:block;
word-wrap: break-word;
text-align: left;
white-space: pre-line;
}
/* expand */
.tooltip.expand:before {
transform: scale3d(.2,.2,1);
transition: all .2s ease-in-out 0.5s;
}
.tooltip.expand:after {
transform: translate3d(0,6px,0);
transition: all .2s ease-in-out 0.5s;
}
.tooltip.expand:hover:before,
.tooltip.expand:hover:after {
opacity: 1;
transform: scale3d(1,1,1);
}
.date_event{
text-align:left; width:232px; position:absolute; padding: 5px 0 0 5px; font-style: italic; max-height:20px; z-index:-1;
}
.suwak{
width:232px; height:150px; margin-left:auto; margin-right:auto; overflow-y:visible; overflow-x:hidden; border:solid 1px #000;
}
.title_event{
font-size:16px; font-weight:bold; width:232px; height:130px; vertical-align: middle !important; display: table-cell !important; margin-left:auto; margin-right:auto;
}
<?php $tooltip = "Lorem ipsum dolor sit amet enim.";
$tooltip = $tooltip."<div class='btn_google'>google</div>"; ?>
<div class="suwak">
<div class="frame" id="basic">
<li class="tooltip expand" data-title="<?php echo $tooltip;?>">
<div class="date_event">02.02.2017</div>
<div style="text-align: center; width:232px;">
<div class="title_event">Some title</div>
</div>
</li>
</div>
</div>
That li is not need, just change it to div
Also why not just add a hidden div block as tooltip container, on hover show it (just like the tooltip):
.expand:hover>div {
display: none;
height: 148px;
width: 232px;
}
.mytitle {
display: none;
}
.expand:hover>.mytitle {
display: block;
background: red;
}
/* Frame */
.frame {
height: 150px;
max-width: 1170px;
/*line-height: 130px;*/
/* overflow:visible !important;*/
}
.frame ul {
list-style: none;
margin: 0;
padding: 0;
height: 100%;
font-size: 14px;
}
.frame ul li {
float: left;
width: 232px;
height: 100%;
margin: 0 2px 0 0;
padding: 0;
background: #f1f1f1;
color: #00b5f6;
text-align: center;
cursor: default;
display: flex;
}
.frame ul li:hover {
color: #fff;
background: #00b5f6;
}
/* setup tooltips */
.tooltip {
position: relative;
z-index: 1;
}
li .tooltip {
overflow: visible;
}
.tooltip:before,
.tooltip:after {
position: absolute;
display: inline-block;
opacity: 0;
pointer-events: none;
width: 225px;
}
.tooltip:after {
border-right: 6px solid transparent;
border-top: 6px solid #00b5f6;
border-left: 6px solid transparent;
content: '';
height: 0;
top: -5px;
left: 20px;
width: 0;
display: none;
}
.tooltip:before {
background: #00b5f6;
border-radius: 2px;
color: #fff;
content: attr(data-title);
font-size: 12px;
padding: 6px 10px;
top: 0px;
left: 0px;
white-space: nowrap;
height: 118px;
max-width: 212px !important;
display: block;
word-wrap: break-word;
text-align: left;
white-space: pre-line;
}
/* expand */
.tooltip.expand:before {
transform: scale3d(.2, .2, 1);
transition: all .2s ease-in-out 0.5s;
}
.tooltip.expand:after {
transform: translate3d(0, 6px, 0);
transition: all .2s ease-in-out 0.5s;
}
.tooltip.expand:hover:before,
.tooltip.expand:hover:after {
opacity: 1;
transform: scale3d(1, 1, 1);
}
.date_event {
text-align: left;
width: 232px;
position: absolute;
padding: 5px 0 0 5px;
font-style: italic;
max-height: 20px;
z-index: -1;
}
.suwak {
width: 232px;
height: 150px;
margin-left: auto;
margin-right: auto;
overflow-y: visible;
overflow-x: hidden;
border: solid 1px #000;
}
.title_event {
font-size: 16px;
font-weight: bold;
width: 232px;
height: 130px;
vertical-align: middle !important;
display: table-cell !important;
margin-left: auto;
margin-right: auto;
}
.expand:hover>div {
display: none;
}
.mytitle {
height: 0px;
width: 0px;
display: none;
}
.expand:hover>.mytitle {
height: 150px;
width: 232px;
display: block;
background: red;
}
<div class="suwak">
<div class="frame" id="basic">
<div class="expand" data-title="">
<div class="mytitle">my title <button>123</button><button>123</button></div>
<div class="date_event">02.02.2017</div>
<div style="text-align: center; width:232px;">
<div class="title_event">Some title</div>
</div>
</div>
</div>
</div>
You can do this without using Javascript. Remove that li and do something like this in a simple way:
.box{
width: 200px;
height: 100px;
position: relative;
background-color: silver;
text-align: center;
}
.box:hover .tip{
display: block;
}
.tip{
display: none;
background-color: yellow;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
<div class="box">
<div class="tip">
This is tip content and this is <button>button</button> in it
</div>
Box content
</div>
UPDATE
from the link that you provided on your comment (uw.edu.pl) This is what you are trying to do:
ul{
list-style: none;
}
ul.main{
display: inline-block;
margin-top: 50px;
}
ul.main>li{
width: 200px;
height: auto;
position: relative;
background-color: silver;
text-align: center;
}
ul li ul{
display: none;
}
ul li a{
display: block;
height: 100%;
text-decoration: none;
color: white;
}
ul li:hover ul{
display: block;
}
ul.tip{
display: none;
background-color: yellow;
position: absolute;
bottom: 100%;
padding: 0;
height: auto;
left: 0;
right: 0;
z-index: 1;
}
<ul class="main">
<li>
Box content 1
<ul class="tip">
<li>
This is tip content and this is <button>button1</button> in it
</li>
</ul>
</li><li>
Box content 2
<ul class="tip">
<li>
This is tip content and this is <button>button2</button> in it
</li>
</ul>
</li><li>
Box content 3
<ul class="tip">
<li>
This is tip content and this is <button>button3</button> in it
</li>
</ul>
</li><li>
Box content 4
<ul class="tip">
<li>
This is tip content and this is <button>button4</button> in it
</li>
</ul>
</li>
</ul>