वहाँ कुछ तरीके जिसके माध्यम से आप img tag
संरेखित और पाठ के लिए कुछ और टैग को जोड़ने और अपनी पहले img के रूप में परिणाम के रूप में आप अपने प्रश्न में कहा है कि प्राप्त कर सकते हैं कर रहे हैं।
समाधान 1: - हमने 2 <p> tags
जोड़ा है। और फिर margin-left
से दूसरे <p> tag
एनएच-बच्चे() चयनकर्ता का उपयोग करके image+10px
की चौड़ाई के बराबर है। और नकारात्मक मूल्य भी img tag
को शीर्ष पर लाने और 2nd <p> tag
को प्रतिस्थापित करने के लिए जोड़ा जाता है।
.box{
width:300px;
margin:auto;
position:relative;
}
.box > p:nth-child(2){
margin-left:110px;
}
.image{
width:100px;
margin-top:-140px;
float:left;
}
<div class="box">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam bibendum hendrerit metus. Vestibulum dignissim cursus ex, eget aliquam leo. Sed at nunc ut orci feugiat vehicula. Integer arcu tellus, bibendum eget ante id, accumsan euismod leo. Nunc volutpat augue id odio fermentum, ut feugiat magna vestibulum. Pellentesque quam ante, tincidunt quis egestas quis, consectetur ut tellus.</p>
<p>
Mauris rutrum odio massa. Donec non molestie ipsum, ac pharetra justo. Phasellus sed orci mollis, lacinia nibh id, scelerisque urna. Praesent nunc elit, feugiat sed quam ut, blandit dignissim est.
</p>
<img src="https://3.bp.blogspot.com/-W__wiaHUjwI/Vt3Grd8df0I/AAAAAAAAA78/7xqUNj8ujtY/s1600/image02.png" class="image" />
</div>
समाधान 2: - हम 2 <p> tags
जोड़ लिया है। लेकिन इस बार img tag or .image
में कोई नकारात्मक मार्जिन जोड़ा नहीं गया है, बस बाएं फ्लोट करें, और 2nd <p> tag
पर कोई मार्जिन-बाएं मान भी नहीं है। वैसे ऐसा इसलिए है क्योंकि हमने float:left for .image
और float:right for 2nd <p> tag
का उपयोग किया था, इसलिए डिफ़ॉल्ट रूप से वे दोनों गठबंधन हो जाते हैं।
.box{
width:300px;
margin:auto;
position:relative;
}
.box > p:nth-child(2){
float:right;
width:180px;
margin:0px;
}
.image{
width:100px;
float:left;
}
<div class="box">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam bibendum hendrerit metus. Vestibulum dignissim cursus ex, eget aliquam leo. Sed at nunc ut orci feugiat vehicula. Integer arcu tellus, bibendum eget ante id, accumsan euismod leo. Nunc volutpat augue id odio fermentum, ut feugiat magna vestibulum. Pellentesque quam ante, tincidunt quis egestas quis, consectetur ut tellus.</p>
<p>
Mauris rutrum odio massa. Donec non molestie ipsum, ac pharetra justo. Phasellus sed orci mollis, lacinia nibh id, scelerisque urna. Praesent nunc elit, feugiat sed quam ut, blandit dignissim est.
</p>
<img src="https://3.bp.blogspot.com/-W__wiaHUjwI/Vt3Grd8df0I/AAAAAAAAA78/7xqUNj8ujtY/s1600/image02.png" class="image" />
</div>
समाधान 3: - अपने पाठ शैली के लिए किसी भी <p> tag
या अन्य टैग जोड़ने की कोई ज़रूरत नहीं है, लेकिन यह अच्छी आदत है, तो आप अपने पाठ के लिए कुछ डिफ़ॉल्ट सौंपा टैग जोड़ें। बस आप में बदलाव करें HTML codes
यानी आपके टेक्स्ट के बीच में <img>
जोड़ें और फिर यह ठीक काम करता है।
.box{
width:300px;
margin:auto;
position:relative;
}
.image{
width:100px;
float:left;
padding:10px 10px 0px 0px;
}
<div class="box">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam bibendum hendrerit metus. Vestibulum dignissim cursus ex, eget aliquam leo. Sed at nunc ut orci feugiat vehicula. Integer arcu tellus, bibendum eget ante id, accumsan euismod leo. Nunc volutpat augue id odio fermentum, ut feugiat magna vestibulum. Pellentesque quam ante, tincidunt quis egestas quis, consectetur ut tellus.
<img src="https://3.bp.blogspot.com/-W__wiaHUjwI/Vt3Grd8df0I/AAAAAAAAA78/7xqUNj8ujtY/s1600/image02.png" class="image" />
Mauris rutrum odio massa. Donec non molestie ipsum, ac pharetra justo. Phasellus sed orci mollis, lacinia nibh id, scelerisque urna. Praesent nunc elit, feugiat sed quam ut, blandit dignissim est.
</div>
मार्जिन टॉप (सकारात्मक मूल्य) - जब हम एक तत्व को margin-top positive value
आवंटित यह ऊपर से उस तत्व को धक्का और अगर यह है कि तुलना में यह नीचे कुछ तत्व है भी नीचे बिट के लिए कदम ।
मार्जिन टॉप (ऋणात्मक मान) - लेकिन जब हम एक तत्व को margin-top negative value
असाइन करते हैं, तो उस बिंदु पर हम उस तत्व एक दूसरे तत्व के एक क्षेत्र है जो अपने आप को पहले से ही खींच यानी सौंपा कुछ गुण है में प्राप्त करने के लिए कर रहे हैं या नीचे शीर्ष पर मजबूर कर रहा है।
यह आपके प्रश्न में भी यही समस्या है, या तो आप HTML कोड i.e. <img>
में टेक्स्ट के बीच में परिवर्तन करते हैं या <p> tag
जोड़ते हैं और काम करते हैं।
कुछ व्यापक पढ़ने के बाद ऐसा लगता है कि ऐसा कुछ ऐसा नहीं है जो करना संभव नहीं है, लेकिन अगर मैं कुछ स्टॉलवार्ट रीडर मुझे गलत साबित कर सकता है तो मैं सवाल उठा रहा हूं। – mmilo