ฉันต้องการออกแบบบล็อกข้อความดังภาพต่อไปนี้:
ถามว่าเป็นไปได้ไหม?
ฉันต้องการออกแบบบล็อกข้อความดังภาพต่อไปนี้:
ถามว่าเป็นไปได้ไหม?
<p>
แท็กปกติเป็นต้น แต่คุณยังพูดถึง<textarea>
ซึ่งอาจเป็นปัญหาที่แตกต่างไปจากเดิมโดยสิ้นเชิง ทำไมคุณไม่โพสต์ HTML ของคุณถ้าคุณมี ขอบคุณ.
คำตอบ:
คุณต้อง float
คอนเทนเนอร์รูปภาพของคุณดังนี้:
HTML
<div id="container">
<div id="floated">...some other random text</div>
...
some random text
...
</div>
CSS
#container{
width: 400px;
background: yellow;
}
#floated{
float: left;
width: 150px;
background: red;
}
ซอ
ด้วยCSS Shapesคุณสามารถไปได้ไกลกว่าเพียงแค่ลอยข้อความรอบ ๆ รูปภาพสี่เหลี่ยม
จริงๆแล้วคุณสามารถตัดข้อความให้เป็นรูปร่างของขอบของรูปภาพหรือรูปหลายเหลี่ยมที่คุณพันไว้รอบ ๆ
.oval {
width: 400px;
height: 250px;
color: #111;
border-radius: 50%;
text-align: center;
font-size: 90px;
float: left;
shape-outside: ellipse();
padding: 10px;
background-color: MediumPurple;
background-clip: content-box;
}
span {
padding-top: 70px;
display: inline-block;
}
<div class="oval"><span>PHP</span>
</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.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.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>
นอกจากนี้นี่คือรายการที่ดีนอกเหนือจากบทความเกี่ยวกับ CSS Shapes
นอกเหนือจากคำตอบของBeNdErR :
องค์ประกอบ "TEXT อื่น ๆ " ควรมีfloat:none
เช่น:
<div style="width:100%;">
<div style="float:left;width:30%; background:red;">...something something something random text</div>
<div style="float:none; background:yellow;"> text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </div>
</div>
หากขนาดรูปภาพเป็นตัวแปรหรือการออกแบบตอบสนองนอกเหนือจากการตัดข้อความคุณสามารถตั้งค่าความกว้างขั้นต่ำสำหรับย่อหน้าเพื่อหลีกเลี่ยงไม่ให้แคบเกินไป
ให้องค์ประกอบหลอก CSS ที่มองไม่เห็นพร้อมความกว้างย่อหน้าต่ำสุดที่ต้องการ ถ้ามีพื้นที่ไม่เพียงพอที่จะใส่องค์ประกอบหลอกนี้มันจะถูกดันลงไปข้างใต้ภาพโดยใช้ย่อหน้าด้วย
#container:before {
content: ' ';
display: table;
width: 10em; /* Min width required */
}
#floated{
float: left;
width: 150px;
background: red;
}