【发布时间】:2023-03-12 16:17:01
【问题描述】:
我正在尝试在 React 中构建一个字段集,这将允许我在外部边框内添加任何元素(例如按钮等)。 我正在寻找一种方法使边框内的元素透明(其中显示“访问我们”),以便页面的真实背景很好地可见。
使用如下实现,背景被明确设置为黑色。我想避免它,并且没有背景。但是,边界线显示出来了。
有没有巧妙的办法解决这个问题?
谢谢!
function ThankYou(){
return(
<div className="thankYouParent">
<div className="thankYouBox">
<label className="borderText"> For visiting us </label>
<label className="thankYouText">Thank You</label>
</div>
</div>
)
}
ReactDOM.render(
<ThankYou />,
root
)
.thankYouParent {
display: flex;
border: 1px dotted red;
flex-direction: column;
align-items: center;
height: 100vh;
justify-content: space-between;
justify-content: center;
}
.thankYouBox {
display: flex;
position: relative;
text-align: center;
border: 5px solid #ffffff;
text-transform: uppercase;
height: 40vh;
width: 75vw;
justify-content: center;
}
.thankYouText {
font-family: interstateBold;
font-size: 10vw;
color: white;
align-self: center;
}
.borderText {
font-family: interstateRegular;
position: absolute;
color: white;
font-size: 3vh;
background-color: black;
padding-left: 1vw;
padding-right: 1vw;
bottom: -1.5vh;
margin-bottom: -3px;
}
body {
background: black;
}
* {
box-sizing: border-box;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="root"></div>
【问题讨论】:
标签: javascript css reactjs