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

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

如何在文本上添加文本

如何在文本上添加文本

aluckdog 2023-11-02 21:24:20
有沒有辦法在 CSS 或 JS 中將文本放在上面的文本上?
查看完整描述

3 回答

?
慕少森

TA貢獻2019條經驗 獲得超9個贊

使用父元素relative position并將文本添加為absolute子元素:


.elements {

  position: relative;

}


.outer-element, .inner-element {

  font-size: 60px;

  font-family: verdana;

  font-weight: bold;

}

.outer-element {

  color: blue;

}

.inner-element {

  position: absolute;

  left: 50px;

  top: 35px;

  color: yellow;

}

<div class="elements">

  <div class="outer-element">GTA</div>

  <div class="inner-element">ROLEPLAY</div>

</div>

代碼小提琴


查看完整回答
反對 回復 2023-11-02
?
隔江千里

TA貢獻1906條經驗 獲得超10個贊

是的,您可以使用 CSS 在圖像前面添加文本。


.container {

? ? ? position: relative;

? ? ? text-align: center;

? ? ? color: white;

? ? }


? ? .firstline {

? ? ? position: absolute;

? ? ? top: 8px;

? ? ? left: 15px;

? ? ? font-size: 50px;

? ? ? font-weight: bold;

? ? ? color: white;

? ? }


? ? .secondtline {

? ? ? position: absolute;

? ? ? top: 22px;

? ? ? left: 40px;

? ? ? font-size: 70px;

? ? ? font-weight: bold;

? ? ? color: orange;

? ? }

<div class="container">

? ? ? <img src="https://www.w3schools.com/howto/img_snow_wide.jpg" alt="Snow" style="width:100%;">

? ? ? <div class="firstline">GTA</div>

? ? ? <div class="secondtline">ROLEPLAY</div>

? ? </div>


查看完整回答
反對 回復 2023-11-02
?
慕蓋茨4494581

TA貢獻1850條經驗 獲得超11個贊

嘗試這個


<div style="position:absolute; top:0;left:0;">some text</div>

<div style="position:absolute; top:5;left:5;">some text</div>

<div style="position:absolute; top:10;left:10;">some text</div>

<br/>

<div style="position:absolute; top:110;left:100;">some text</div>

<div style="position:absolute; top:105;left:105;">some text</div>

<div style="position:absolute; top:100;left:110;">some text</div>


查看完整回答
反對 回復 2023-11-02
  • 3 回答
  • 0 關注
  • 196 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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