亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

css 混合/模糊/合并背景圖像

css 混合/模糊/合并背景圖像

BIG陽 2023-10-24 21:20:53
我在一個網站上工作,這只是 ReactJS 中的一個演示: https: //poc-bio-meteo.netlify.com/問題在于背景。這個概念很簡單,該應用程序由 4 個部分組成,頂部是沒有背景的meteo,另外 3 個部分有不同的背景。該應用程序必須是移動且響應式的,每個部分都有不同的內容,因此高度也不同?,F在我想在每個部分(météo & 1; 1&2; 2&3)之間做出很好的效果,如下所示:那么如何使每個部分都位于前一個部分的底部的某個像素上,并使其很好地融合在一起(就像我們可以在 Photoshop 中使用 2 個 png 和透明度一樣)。這種效果應該在 css 中完成,因為它應該從移動設備到寬屏幕都存在。以前我嘗試過:對于包含透明的 3 個 png,它不適用于兩個存在的理由。PNG 太重了,而且它只顯示了精確的屏幕寬度。通過在組件的底部/頂部添加一個相對區域,Categorie但linear-gradient渲染得有點難看1) 應用程序.JSimport Meteo from "./components/Meteo";import Categorie from "./components/Categorie";function App() {  return (    <div className="App">      <h5 style={{ paddingLeft: 15 }}>Météo</h5>      <header className="App-header">        <Meteo />        <Categorie name="air" display="Air" bgpos="bottom" {/* bottomOpacity*/} />        <Categorie name="sol" display="Sol" bgpos="center"  {/*  bottomOpacity topOpacity*/} />        <Categorie name="eau" display="Eau" bgpos="top" {/* topOpacity */}/>      </header>    </div>  );}2)類別.jsconst useStyles = makeStyles(theme => ({  root: {    flexGrow: 1  },  leftText: {    textAlign: "left",    width: "auto",    display: "inline-block"  },  responsive: {    width: "100%",    maxWidth: "1000px",    height: "auto"  },  container: {    display: "flex",    flexDirection: "column",    alignItems: "center",    justifyContent: "center"  },  overlay: {    backgroundColor: "rgba(13,53,78, 0.6)",    color: "white",    position: "relative"  },  topOpacity: {    position: "absolute",    top: -2,    width: "100%",    height: 75,    background: "linear-gradient( to top, transparent , rgba(13,53,78,0.9 ) )",    backgroundRepeat: "no-repeat"  },  bottomOpacity: {    position: "absolute",    bottom: -2,    width: "100%",    height: 75,    background:      "linear-gradient( to bottom, transparent , rgba(13,53,78, 0.9 ) )",    backgroundRepeat: "no-repeat"  },  padding: {    padding: "auto",    paddingTop: 85,    paddingBottom: 85  }}));
查看完整描述

1 回答

?
絕地無雙

TA貢獻1946條經驗 獲得超4個贊

這可以使用掩模來完成。


這是一個簡化的示例:


.box {

  height:60vh;

  font-size:50px;

  text-align:center;

  color:#fff;

  position:relative;

  z-index:0;

}

.box:before {

  content:"";

  position:absolute;

  z-index:-1;

  left:0;

  right:0;

  top:-50px;

  bottom:-50px;

  background:var(--img) center/cover;

  -webkit-mask:linear-gradient(transparent ,#fff 50px calc(100% - 50px),transparent);

          mask:linear-gradient(transparent ,#fff 50px calc(100% - 50px),transparent);

}

<div class="box" style="--img:url(https://picsum.photos/id/1002/800/800.jpg)">text 1</div>

<div class="box" style="--img:url(https://picsum.photos/id/109/800/800.jpg)">text 2</div>

<div class="box" style="--img:url(https://picsum.photos/id/107/800/800.jpg)">text 3</div>

<div class="box" style="--img:url(https://picsum.photos/id/177/800/800.jpg)">text 4</div>

查看完整回答
反對 回復 2023-10-24
  • 1 回答
  • 0 關注
  • 151 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號