Home Web Front-end CSS Tutorial Picture magnifying glass effect implemented by CSS3

Picture magnifying glass effect implemented by CSS3

Jun 26, 2018 pm 01:29 PM
css3 magnifier

A picture magnifying glass effect implemented using pure CSS3. The page opens and five small images are displayed on the page. When the mouse passes over the picture, the current picture will be displayed in the form of a gray background image. Friends who need it should not miss the picture magnifying glass effect that I will share with you today using pure CSS3. The page opens and five small images are displayed on the page. When the mouse passes over the picture, the current picture is displayed in the form of a gray background image. The effect is very good.


Implemented code:

html code:

1

2

3

4

5

6

7

8

<ul class="gallery">

<li class="gallery__item"></li>

<li class="gallery__item"></li>

<li class="gallery__item"></li>

<li class="gallery__item"></li>

<li class="gallery__item"></li>

<li class="gallery__item"></li>

</ul>

Copy after login

css code:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

.gallery

{

list-style: none;

}

.gallery:before, .gallery__item:last-child

{

position: fixed;

top: 50%;

left: 50%;

margin: -31.25em;

width: 62.5em;

height: 62.5em;

}

.gallery:before

{

z-index: -1;

border-radius: 50%;

content: &#39;&#39;;

box-shadow: inset 0 0 5em dimgrey, 0 0 0 50vw dimgrey;

}

.gallery__item

{

background-blend-mode: luminosity;

transition: -webkit-transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-image 0.5s;

}

.gallery__item:not(:last-child)

{

position: absolute;

top: 50%;

left: 50%;

width: 32vmin;

height: 32vmin;

border-radius: 50%;

box-shadow: 0 0 .5em white;

}

.gallery__item:nth-child(1)

{

margin: 13.87457vmin -4.53223vmin;

-webkit-transform: scale(0.5);

background: url("imgs/1.jpg") 50% 50% fixed whitesmoke;

}

.gallery__item:nth-child(1):hover

{

-webkit-transform: scale(1);

background-blend-mode: normal;

cursor: pointer;

}

.gallery__item:nth-child(1):hover ~ :last-child

{

background: url("imgs/1.jpg") 50% 50% fixed dimgray;

}

.gallery__item:nth-child(1):hover ~ :last-child:after

{

opacity: .001;

}

.gallery__item:nth-child(2)

{

margin: 4.13825vmin -40.86867vmin;

-webkit-transform: scale(0.5);

background: url("imgs/2.jpg") 50% 50% fixed whitesmoke;

}

.gallery__item:nth-child(2):hover

{

-webkit-transform: scale(1);

background-blend-mode: normal;

cursor: pointer;

}

.gallery__item:nth-child(2):hover ~ :last-child

{

background: url("imgs/2.jpg") 50% 50% fixed dimgray;

}

.gallery__item:nth-child(2):hover ~ :last-child:after

{

opacity: .001;

}

.gallery__item:nth-child(3)

{

margin: -33.42845vmin -42.83746vmin;

-webkit-transform: scale(0.5);

background: url("imgs/3.jpg") 50% 50% fixed whitesmoke;

}

.gallery__item:nth-child(3):hover

{

-webkit-transform: scale(1);

background-blend-mode: normal;

cursor: pointer;

}

.gallery__item:nth-child(3):hover ~ :last-child

{

background: url("imgs/3.jpg") 50% 50% fixed dimgray;

}

.gallery__item:nth-child(3):hover ~ :last-child:after

{

opacity: .001;

}

.gallery__item:nth-child(4)

{

margin: -46.90963vmin -7.71779vmin;

-webkit-transform: scale(0.5);

background: url("imgs/4.jpg") 50% 50% fixed whitesmoke;

}

.gallery__item:nth-child(4):hover

{

-webkit-transform: scale(1);

background-blend-mode: normal;

cursor: pointer;

}

.gallery__item:nth-child(4):hover ~ :last-child

{

background: url("imgs/4.jpg") 50% 50% fixed dimgray;

}

.gallery__item:nth-child(4):hover ~ :last-child:after

{

opacity: .001;

}

.gallery__item:nth-child(5)

{

margin: -17.67475vmin 15.95615vmin;

-webkit-transform: scale(0.5);

background: url("imgs/5.jpg") 50% 50% fixed whitesmoke;

}

.gallery__item:nth-child(5):hover

{

-webkit-transform: scale(1);

background-blend-mode: normal;

cursor: pointer;

}

.gallery__item:nth-child(5):hover ~ :last-child

{

background: url("imgs/5.jpg") 50% 50% fixed dimgray;

}

.gallery__item:nth-child(5):hover ~ :last-child:after

{

opacity: .001;

}

.gallery__item:last-child

{

z-index: -2;

}

.gallery__item:last-child:after

{

position: absolute;

top: 0;

right: 0;

bottom: 0;

left: 0;

opacity: .999;

background: dimgrey;

transition: opacity 2s;

content: &#39;&#39;;

}

Copy after login

The above is the entire article Content, I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Some tips on making border effects with CSS


Compatible with IE’s inner shadow and outer shadow Implementation effect and test code


CSS to achieve the effect of text surrounding images


The above is the detailed content of Picture magnifying glass effect implemented by CSS3. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to achieve wave effect with pure CSS3? (code example) How to achieve wave effect with pure CSS3? (code example) Jun 28, 2022 pm 01:39 PM

How to achieve wave effect with pure CSS3? This article will introduce to you how to use SVG and CSS animation to create wave effects. I hope it will be helpful to you!

Use CSS skillfully to realize various strange-shaped buttons (with code) Use CSS skillfully to realize various strange-shaped buttons (with code) Jul 19, 2022 am 11:28 AM

This article will show you how to use CSS to easily realize various weird-shaped buttons that appear frequently. I hope it will be helpful to you!

How to hide elements in css without taking up space How to hide elements in css without taking up space Jun 01, 2022 pm 07:15 PM

Two methods: 1. Using the display attribute, just add the "display:none;" style to the element. 2. Use the position and top attributes to set the absolute positioning of the element to hide the element. Just add the "position:absolute;top:-9999px;" style to the element.

How to implement lace borders in css3 How to implement lace borders in css3 Sep 16, 2022 pm 07:11 PM

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

How to enlarge the image by clicking the mouse in css3 How to enlarge the image by clicking the mouse in css3 Apr 25, 2022 pm 04:52 PM

Implementation method: 1. Use the ":active" selector to select the state of the mouse click on the picture; 2. Use the transform attribute and scale() function to achieve the picture magnification effect, the syntax "img:active {transform: scale(x-axis magnification, y Axis magnification);}".

It turns out that text carousel and image carousel can also be realized using pure CSS! It turns out that text carousel and image carousel can also be realized using pure CSS! Jun 10, 2022 pm 01:00 PM

How to create text carousel and image carousel? The first thing everyone thinks of is whether to use js. In fact, text carousel and image carousel can also be realized using pure CSS. Let’s take a look at the implementation method. I hope it will be helpful to everyone!

How to set animation rotation speed in css3 How to set animation rotation speed in css3 Apr 28, 2022 pm 04:32 PM

In CSS3, you can use the "animation-timing-function" attribute to set the animation rotation speed. This attribute is used to specify how the animation will complete a cycle and set the speed curve of the animation. The syntax is "element {animation-timing-function: speed attribute value;}".

How to implement image magnifying glass effect with JavaScript? How to implement image magnifying glass effect with JavaScript? Oct 18, 2023 am 08:45 AM

How to achieve image magnifying glass effect with JavaScript? In web design, the image magnifying glass effect is often used to display detailed product images. When the mouse is hovering over the image, a magnifying lens can be displayed at the mouse position to enlarge part of the image, thereby providing a clearer display of details. This article will introduce how to use JavaScript to achieve the image magnifying glass effect and provide code examples. 1. HTML structure First, you need to create a page layout with a magnifying glass. In HTML text

See all articles