可以將html元素按特定高度拆分為兩個連續的部分,并使用javascript自動在它們之間添加另一個元素,例如將圖像拆分為兩個部分并在它們之間添加其他圖像。例子 :p { width: 300px;}.original-div { border: 1px solid black;}.div1 { border-bottom: none;}.div1 p { margin-bottom: 0;}.div2 { border-top: none;}.div2 p { margin-top: 0;}.new-elem { font-weight: bold; border: 2px solid red; background-color: blue; color: white;}<strong>Original</strong><hr/><div class="original-div"> <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><br/><strong>Output</strong><hr/><div class="original-div div1"> <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 </p></div><div class="new-elem"> INSERTED ELEMENT</div><div class="original-div div2"> <p> 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>
如何將元素拆分為兩個連續的部分并在它們之間添加另一個元素
料青山看我應如是
2021-05-14 14:12:03