欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CSS3波浪效果示例(前端必學(xué))

  發(fā)布時(shí)間:2023-05-08 14:41:37   作者:國服第二切圖仔   我要評(píng)論
隨著前端技術(shù)的不斷發(fā)展與進(jìn)步,界面交互的樣式要求和美感也越來越高,很多網(wǎng)頁的交互都加上了css3動(dòng)畫,這里作者給大家分享一個(gè)前端開發(fā)必掌握的一個(gè)CSS3波浪效果

CSS3波浪效果展示:

這是使用 SVG 和 CSS 動(dòng)畫制作的波浪效果,上半部分是藍(lán)色(可修改成其他顏色)漸變的背景顏色,下半部分就是波浪,有四條波浪在不停的來回起伏,非常逼真。該波浪效果可用于大部分頁面的底部,使頁面增加一點(diǎn)活潑的氣息。

1.Html構(gòu)建

代碼如下(示例):

<div class="inner_header"> 填充藍(lán)色(可修改成其他顏色)漸變的背景顏色

<div class="waves">這部分就是波浪的svg,有四條波浪在不停的來回起伏,效果非常逼真

 
		<div class="header">
			<div class="inner-header flex">
				<h1>簡單的 CSS3 波浪效果</h1>
			</div>
			<div>
				<svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
					viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
					<defs>
						<path id="gentle-wave"
							d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
					</defs>
					<g class="parallax">
						<use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(255,255,255,0.7" />
						<use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(255,255,255,0.5)" />
						<use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(255,255,255,0.3)" />
						<use xlink:href="#gentle-wave" x="48" y="7" fill="#fff" />
					</g>
				</svg>
			</div>
		</div>

2.CSS編寫

代碼如下(示例):

這里通過CSS3的animation動(dòng)畫屬性來控制四條線條在不停的來回起伏,形成波浪效果

 
 
.header {
    position: relative;
    text-align: center;
    background: linear-gradient(60deg, rgba(84, 58, 183, 1) 0%, rgba(0, 172, 193, 1) 100%);
/* 	background: #FFAFBD;  
	background: -webkit-linear-gradient(to right, #ffc3a0, #FFAFBD);  
	background: linear-gradient(to right, #ffc3a0, #FFAFBD); 
 */
    color: white;
}
 
 
.inner-header {
    height: 65vh;
    width: 100%;
    margin: 0;
    padding: 0;
}
 
 
 
.waves {
    position: relative;
    width: 100%;
    height: 15vh;
    margin-bottom: -7px; /*Fix for safari gap*/
    min-height: 100px;
    max-height: 150px;
}
 
.content {
    position: relative;
    height: 20vh;
    text-align: center;
    background-color: white;
}
 
.content a {
    margin: 0 5px;
    font-size: 12px;
    color: #333;
}
 
.content a:hover {
    color: #000;
}
 
/* Animation */
 
.parallax > use {
    animation: move-forever 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
}
.parallax > use:nth-child(1) {
    animation-delay: -2s;
    animation-duration: 7s;
}
.parallax > use:nth-child(2) {
    animation-delay: -3s;
    animation-duration: 10s;
}
.parallax > use:nth-child(3) {
    animation-delay: -4s;
    animation-duration: 13s;
}
.parallax > use:nth-child(4) {
    animation-delay: -5s;
    animation-duration: 20s;
}
@keyframes move-forever {
    0% {
        transform: translate3d(-90px, 0, 0);
    }
    100% {
        transform: translate3d(85px, 0, 0);
    }
}
/*Shrinking for mobile*/
@media (max-width: 768px) {
    .waves {
        height: 40px;
        min-height: 40px;
    }
    .content {
        height: 30vh;
    }
    h1 {
        font-size: 24px;
    }
}

3.完整代碼

index.html文件

<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8" />
		<title>簡單的CSS3波浪效果演示_dowebok</title>
		<link rel="stylesheet" href="style.css" />
	</head>
	<body>
		<div class="header">
			<div class="inner-header flex">
				<h1>簡單的 CSS3 波浪效果</h1>
			</div>
			
			<div>
				<svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
					viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
					<defs>
						<path id="gentle-wave"
							d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
					</defs>
					<g class="parallax">
						<use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(255,255,255,0.7" />
						<use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(255,255,255,0.5)" />
						<use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(255,255,255,0.3)" />
						<use xlink:href="#gentle-wave" x="48" y="7" fill="#fff" />
					</g>
				</svg>
			</div>
		</div>
 
 
	</body>
</html>

style.css文件

body {
    margin: 0;
}
 
h1 {
    font-family: 'Lato', sans-serif;
    font-weight: 300;
    letter-spacing: 2px;
    font-size: 48px;
}
p {
    font-family: 'Lato', sans-serif;
    letter-spacing: 1px;
    font-size: 14px;
    color: #333333;
}
 
.header {
    position: relative;
    text-align: center;
    background: linear-gradient(60deg, rgba(84, 58, 183, 1) 0%, rgba(0, 172, 193, 1) 100%);
/* 	background: #FFAFBD;  
	background: -webkit-linear-gradient(to right, #ffc3a0, #FFAFBD);  
	background: linear-gradient(to right, #ffc3a0, #FFAFBD); 
 */
    color: white;
}
.logo {
    width: 50px;
    fill: white;
    padding-right: 15px;
    display: inline-block;
    vertical-align: middle;
}
 
.inner-header {
    height: 65vh;
    width: 100%;
    margin: 0;
    padding: 0;
}
 
.flex {
    /*Flexbox for containers*/
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}
 
.waves {
    position: relative;
    width: 100%;
    height: 15vh;
    margin-bottom: -7px; /*Fix for safari gap*/
    min-height: 100px;
    max-height: 150px;
}
 
.content {
    position: relative;
    height: 20vh;
    text-align: center;
    background-color: white;
}
 
.content a {
    margin: 0 5px;
    font-size: 12px;
    color: #333;
}
 
.content a:hover {
    color: #000;
}
 
/* Animation */
 
.parallax > use {
    animation: move-forever 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
}
.parallax > use:nth-child(1) {
    animation-delay: -2s;
    animation-duration: 7s;
}
.parallax > use:nth-child(2) {
    animation-delay: -3s;
    animation-duration: 10s;
}
.parallax > use:nth-child(3) {
    animation-delay: -4s;
    animation-duration: 13s;
}
.parallax > use:nth-child(4) {
    animation-delay: -5s;
    animation-duration: 20s;
}
@keyframes move-forever {
    0% {
        transform: translate3d(-90px, 0, 0);
    }
    100% {
        transform: translate3d(85px, 0, 0);
    }
}
/*Shrinking for mobile*/
@media (max-width: 768px) {
    .waves {
        height: 40px;
        min-height: 40px;
    }
    .content {
        height: 30vh;
    }
    h1 {
        font-size: 24px;
    }
}

到此這篇關(guān)于CSS3波浪效果示例(前端必學(xué))的文章就介紹到這了,更多相關(guān)CSS3波浪效果內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

  • css3中2D轉(zhuǎn)換之有趣的transform形變效果

    在CSS3中,transform屬性應(yīng)用于元素的2D或3D轉(zhuǎn)換,可以利用transform功能實(shí)現(xiàn)文字或圖像的旋轉(zhuǎn)、縮放、傾斜、移動(dòng)這4中類型的形變處理,本文給大家介紹css3中2D轉(zhuǎn)換之有趣
    2022-02-18
  • css3帶你實(shí)現(xiàn)3D轉(zhuǎn)換效果

    這篇文章主要介紹了css3帶你實(shí)現(xiàn)3D轉(zhuǎn)換效果,本篇的3D轉(zhuǎn)換就是基于原來的2D轉(zhuǎn)換而來,與2D轉(zhuǎn)換的功能相似,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-02-18
  • CSS3 Tab動(dòng)畫實(shí)例之背景切換動(dòng)態(tài)效果

    這篇文章主要介紹了CSS3 Tab動(dòng)畫實(shí)例之背景切換動(dòng)態(tài)效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-08-20
  • 純CSS3實(shí)現(xiàn)div按照順序出入效果

    本文主要介紹了純CSS3實(shí)現(xiàn)div按照順序出入效果,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-07-14
  • CSS3實(shí)現(xiàn)列表無限滾動(dòng)/輪播效果

    本文給大家分享CSS3實(shí)現(xiàn)列表無限滾動(dòng)/輪播效果,實(shí)現(xiàn)思路大概是將當(dāng)前列表滾動(dòng)至最后一項(xiàng)的末尾,然后瞬間切換回第一項(xiàng),怎么實(shí)現(xiàn)無限輪播效果,下面小編給大家?guī)砹藢?shí)現(xiàn)
    2021-06-22
  • CSS3實(shí)現(xiàn)的3D隧道效果

    這篇文章主要介紹了CSS3實(shí)現(xiàn)的3D隧道效果,幫助大家更好的理解和學(xué)習(xí)使用CSS3,感興趣的朋友可以了解下
    2021-04-26
  • css3 實(shí)現(xiàn)文字閃爍效果的三種方式示例代碼

    這篇文章主要介紹了css3 實(shí)現(xiàn)文字閃爍效果的三種方式示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編
    2021-04-25
  • 六種css3實(shí)現(xiàn)的邊框過渡效果

    這篇文章主要介紹了六種css3實(shí)現(xiàn)的邊框過渡效果,幫助大家更好的理解和學(xué)習(xí)使用CSS3,感興趣的朋友可以了解下
    2021-04-22
  • CSS3鼠標(biāo)懸浮過渡縮放效果

    這篇文章主要介紹了CSS3鼠標(biāo)懸浮過渡縮放效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-04-16
  • CSS3 制作的圖片滾動(dòng)效果

    這篇文章主要介紹了CSS3 制作的圖片滾動(dòng)效果,幫助大家更好的理解和學(xué)習(xí)使用CSS3,感興趣的朋友可以了解下
    2021-04-14

最新評(píng)論