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

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

如何將一些文本放入另一個文本節點的第一行末尾 (p)

如何將一些文本放入另一個文本節點的第一行末尾 (p)

德瑪西亞99 2023-10-30 15:33:20
我想在段落的第一行最后位置放置一些文本。我如何使用 css 來做到這一點? (如果這對 CSS 來說是不可能的,那么我該如何用 JS 做到這一點)我想要像下面這樣https://i.stack.imgur.com/VIk9n.png
查看完整描述

2 回答

?
慕容3067478

TA貢獻1773條經驗 獲得超3個贊

一種方法是使用float


.small-text{

? float: right;

? font-weight: italic;

? font-size:.8rem;

? color:grey

}

<br/>

<div>

? <span class="small-text"> March 07, 5:45pm </span>

? <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum

? </p>

<div>


查看完整回答
反對 回復 2023-10-30
?
catspeake

TA貢獻1111條經驗 獲得超0個贊

使用CSS


<!DOCTYPE html>

<html>

    <body>

        <br/>

<div>

    <span style="float: right;font-weight: italic;font-size:.8rem;color:grey"> March 07, 5:45pm </span>

    <p style="text-align: right;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum

    </p>

<div>

    </body>

</html>


使用JavaScript


<!DOCTYPE html>

<html>

    <body>

        <p id="p1">Lorem ipsum dolor sit amet consectetur adipisicing elit.<br>Quaerat quas tenetur aliquam ipsum vitae, excepturi, accusamus <br> vel nostrum obcaecati praesentium neque id inventore laborum <br>distinctio quam dolor ullam consectetur nesciunt?</p>

    </body>

    <script>

        var textnode = document.createTextNode(" March 07,5:45pm");  // Create a text node

        var p = document.getElementById("p1");    // Get the <ul> element to insert a new node

        p.insertBefore(textnode, p.childNodes[1]);  // Insert <li> before the first child of <ul>


    </script>

</html>


查看完整回答
反對 回復 2023-10-30
  • 2 回答
  • 0 關注
  • 117 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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