HTML / CSS का उपयोग करके छवि के चारों ओर टेक्स्ट कैसे लपेटें


106

मैं निम्नलिखित चित्र की तरह पाठ का एक खंड डिजाइन करना चाहता हूं:

यहां छवि विवरण दर्ज करें

सवाल है कि क्या यह संभव है?



क्या आप नियमित रूप से <p>टैग के रूप में एक छवि के चारों ओर पाठ लपेटने की कोशिश कर रहे हैं , लेकिन आपने भी उल्लेख किया है <textarea>, जो एक पूरी तरह से अलग समस्या हो सकती है। यदि आपके पास कुछ है तो आप अपना HTML पोस्ट क्यों नहीं करते हैं? धन्यवाद।
मार्क ऑडिट

1
हाँ, आप बस बाईं ओर php छवि फ्लोट करेंगे, और पाठ इसके चारों ओर
लपेटेंगे

इन सभी टिप्पणियों और कोई स्वीकृत उत्तर नहीं ...
डेव कैंटर

जवाबों:


110

आप floatअपनी छवि कंटेनर में निम्नानुसार है:

एचटीएमएल

<div id="container">
    <div id="floated">...some other random text</div>
    ...
    some random text
    ...
</div>

सीएसएस

#container{
    width: 400px;
    background: yellow;
}
#floated{
    float: left;
    width: 150px;
    background: red;
}

बेला

http://jsfiddle.net/kYDgL/


51

CSS Shapes के साथ आप आयताकार छवि के चारों ओर सिर्फ फ्लोट टेक्स्ट की तुलना में एक कदम आगे जा सकते हैं।

आप वास्तव में पाठ को ऐसे लपेट सकते हैं कि वह उस छवि या बहुभुज के किनारे का आकार ले ले जो आप उसे लपेट रहे हैं।

डेमो FIDDLE (वर्तमान में webkit - caniuse पर काम कर रहा है)

.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 पर एक अच्छी सूची अलग लेख है


1
क्या कोई विकल्प है कि वस्तु को "AROUND" में कैसे लपेटें ताकि वस्तु बीच में आ सके?
रेडस्ट्रक्टा

@redestructa CSS बहिष्करण की जाँच करें। मेरी पोस्ट देखें: stackoverflow.com/a/19895616/703717 यह वर्तमान में केवल IE में समर्थित है - caniuse.com/#feat=css-exclusions
Danield

20

के अलावा BeNdErR के जवाब:
"अन्य पाठ" तत्व होना चाहिए 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>


यह एकमात्र तरीका है जिससे मैं काम कर सकता हूं .. और सबसे साफ समाधान।
andygoestohollywood

फ्लोट: कोई भी मुझे बचा लिया गया था! तैरने की कोशिश कर रहा: कोई फायदा नहीं हुआ दूसरा तत्व सही।
bkunzi01

11

यदि छवि का आकार परिवर्तनशील है या डिज़ाइन उत्तरदायी है , तो पाठ को लपेटने के अलावा, आप पैराग्राफ के लिए न्यूनतम चौड़ाई निर्धारित कर सकते हैं ताकि वह बहुत संकीर्ण न हो सके।
वांछित न्यूनतम पैराग्राफ चौड़ाई के साथ एक अदृश्य सीएसएस छद्म तत्व दें। यदि इस छद्म तत्व को फिट करने के लिए पर्याप्त स्थान नहीं है, तो इसे पैराग्राफ के साथ लेते हुए, छवि के नीचे धकेल दिया जाएगा।

#container:before {
  content: ' ';
  display: table;
  width: 10em;    /* Min width required */
}
#floated{
    float: left;
    width: 150px;
    background: red;
}

मुझे लगता है कि आपका जवाब मुझे कुछ बेकन बचा सकता है। मैं एक संवेदनशील डिजाइन में खड़ी बाईं छवियों के साथ एक समस्या थी। मेरी डिफ़ॉल्ट छवि की चौड़ाई 30% होने के साथ-साथ दोनों तरफ की छवियां, मैं कभी-कभी केवल 4 वर्णों वाला एक पाठ स्तंभ ले सकता था।
शेरवुड बॉट्सफ़ोर्ड
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.