How to use resize to implement image switching preview function

How to use resize to implement image switching preview function

Key Points

  • The CSS resize property allows you to control the resizable nature of an element.
  • Use resize to achieve dynamic width of sub-elements

HTML:

<div class='picA'>
    <div class='picB'>
        <div readonly class='resizeElement'></div>
    </div>
</div>

SCSS:

html {
    background: #ddd;
    height: 100%;
    width: 100%;
}
.picA {
    background-image: url(https://z3.ax1x.com/2021/08/17/fhJdpQ.png);
    background-size: cover;
    width: 650px;
    height: 340px;
    border: 5px solid #f0e5ab;
    border-radius: 3px;
    box-shadow: 0 0 1px #999, -2px 2px 3px rgba(0, 0, 0, 0.2);
    padding: 0;
    margin: 1rem auto;
    position: relative;
    overflow: hidden;
}
.picB {
    background-image: url(https://z3.ax1x.com/2021/08/17/fhJUfg.png);
    background-size: cover;
    height: 340px;
    position: absolute;
    top: 0;
    left: 0;
    min-width: 0;
    max-width: 650px;
    box-sizing: border-box;
}
.picB:before {
    content: "↔";
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    font-size: 16px;
    color: white;
    top: 0;
    right: 0;
    height: 100%;
    line-height: 340px;
}
.resizeElement {
    resize: horizontal;
    overflow: scroll;
    opacity: 0;
    position: relative;
    top: 50%;
    left: 0px;
    height: 15px;
    max-width: 650px;
    min-width: 15px;
    width: 0;
    cursor: move;
    transform: scaleY(35);
    transform-origin: center center;
    animation: delta 5s normal ease-in-out 1s;
}
@keyframes delta {
    30% {
        width: 0;
    }
    60% {
        width: 350px;
    }
    100% {
        width: 0;
    }
}

The effect is as follows:

This is the end of this article on how to use resize to implement the image switching preview function. For more relevant resize image switching preview content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  How to design and create adaptive web pages

>>:  CentOS system rpm installation and configuration of Nginx

Recommend

Vue project code splitting solution

Table of contents background Purpose Before split...

JavaScript Design Pattern Command Pattern

The command pattern is a behavioral design patter...

Detailed explanation of the use of CSS pointer-events attribute

In front-end development, we are in direct contac...

How to transfer files between Docker container and local machine

To transfer files between the host and the contai...

Solution to transparent font problem after turning on ClearType in IE

The solution to the transparent font problem after...

Example code of vue + element ui to realize player function

The display without the effect picture is just em...

Vue implements time countdown function

This article example shares the specific code of ...

An Uncommon Error and Solution for SQL Server Full Backup

1. Error details Once when manually performing a ...

How to use the WeChat Mini Program lottery component

It is provided in the form of WeChat components. ...

In-depth understanding of the role of Vuex

Table of contents Overview How to share data betw...

MySQL 8.0.16 winx64 installation and configuration method graphic tutorial

I just started learning about databases recently....

Solution to inserting a form with a blank line above and below

I don't know if you have noticed when making a...

jQuery realizes the sliding effect of drop-down menu

When we make a web page, sometimes we want to hav...

Vue implements the drag and drop sorting function of the page div box

vue implements the drag and drop sorting function...