javascript - 两个 div 共享相同的线性渐变背景
问题描述
我有两个子 div,我希望它们具有相同的线性渐变背景,顶部 div 是动态的,它向左、向右和居中移动,所以我希望与底部 div 具有相同的背景。
#pool-container {
width: 100%;
margin: 0 5px 0 5px;
display: flex;
flex-direction: column;
#side-step {
background: linear-gradient( 120deg, rgba(248, 201, 129, 1) 0%, rgba(227, 76, 145, 1) 100%);
}
#main-pool {
width: 100%;
background: linear-gradient( 120deg, rgba(248, 201, 129, 1) 0%, rgba(227, 76, 145, 1) 100%);
}
<div id="pool-container">
<div id="side-step"></div>
<div id="main-pool"></div>
</div>
解决方案
这是一个如何做到的
有更好的方法吗?老实说,我不知道。
#pool-container {
width: 800px;
height: 600px;
margin: 0 5px 0 5px;
display: flex;
flex-direction: column;
background: #119955;
padding: 15px;
}
#wrapper {
background: linear-gradient( 120deg, rgba(248, 201, 129, 1) 0%, rgba(227, 76, 145, 1) 100%);
width: 100%;
height: 100%;
}
#excluded-area {
width: 50%;
height: 200px;
background: #119955
}
#side-step {
width: 50%;
height: 200px;
}
#main-pool {
width: 100%;
height: 200px;
}
<div id="pool-container">
<div id="wrapper">
<div id="excluded-area"></div>
<div id="side-step"></div>
<div id="main-pool"></div>
</div>
</div>
推荐阅读
- python - 使用分配的变量将每个其他字母大写
- java - 如何使用 Java 的可选功能
- javascript - 如何从数组按钮传递参数
- ruby - JavaScript 替代 Ruby 的 force_encoding(Encoding::ASCII_8BIT)
- c++ - 你如何绘制垂直条?
- python - 根据熊猫中的列和行制作长数据框
- python - beautifulsoupobject.findAll() 返回一个空列表
- sql-server - 无法加载 Microsoft Sql Server Management Studio 18 (SSMS) v18.5
- javascript - 在 MVC 中选中复选框时如何订阅 AJAX
- html - 单击Angular 9中的按钮时如何更改src图像