使用HTML和CSS在网页中并排包装文本[复制]

问题描述 投票:-2回答:2

这个问题在这里已有答案:

我想把两个部分包起来并将它们并排包裹起来,使它们看起来像这样。

<div class="row">


  <span class="pull-left"><strong>5 Dolor et’s face it – no matter how excited you are about a new project or priority in your life, there will always be days when your
		   motivation lags. Days when – despite all the progress you’ve made in the past – it just sounds easier to sit on the couch playing video
		   </strong></span>

  <span>Let’s face it – no matter how excited you are about a new project or priority in your life, there will always be days when your motivation lags. Days when – despite all
		  the progress you’ve made in the past – it just sounds easier to sit on the couch playing video games than to buckle down and crank out the work needed to meet your goals.
          If you don't like your destiny, don't accept it.</span>

</div>
html css textwrapping
2个回答
4
投票

看看这个例子

 .insert { float:right;width:50%; padding:30px;}
<p>
CSS (Cascading Style Sheets) is a style sheet language used for describing the look and formatting of HTML (Hyper Text Markup Language), XML (Extensible Markup Language) documents and SVG elements including (but not limited to) colors, layout, and fonts.CSS (Cascading Style Sheets) is a style sheet language used for describing the look and formatting of HTML (Hyper Text Markup Language), XML (Extensible Markup Language) documents and
<span class="insert">
	CSS (Cascading Style Sheets) is a style sheet language used for describing the look and formatting of HTML (Hyper Text Markup Language), XML (Extensible Markup Language) documents and SVG elements including (but not limited to) colors, layout, and fonts.
</span>
SVG elements including (but not limited to) colors, layout, and fonts.CSS (Cascading Style Sheets) is a style sheet language used for describing the look and formatting of HTML (Hyper Text Markup Language), XML (Extensible Markup Language) documents and SVG elements including (but not limited to) colors, layout, and fonts.CSS (Cascading Style Sheets) is a style sheet language used for describing the look and formatting of HTML (Hyper Text Markup Language), XML (Extensible Markup Language) documents and SVG elements including (but not limited to) colors, layout, and fonts.
look and formatting of HTML (Hyper Text Markup Language), XML (Extensible Markup Language) documents and SVG elements including (but not limited to) colors, layout, and fonts.CSS (Cascading Style Sheets) is a style sheet language used for describing the look and formatting of HTML (Hyper Text Markup Language), XML (Extensible Markup Language) documents and SVG elements including (but not limited to) colors, layout, and fonts.
</p>

0
投票

您可以将零宽度框浮动到右侧以向下移动插入文本,而不必将插入文本放在正文文本的中间。然后,您可以先插入插入文本,然后使用float和clear将其放在正确的位置。

.row::before{
  content:'';
  float:right;
  height:100px;
}
.inset {
  float:right;
  clear:right;
  width:60%;
  font-style:italic;
  margin-left:10px;
}
<div class="row">

  <div class="inset"><strong>5 Dolor et’s face it – no matter how excited you 
are about a new project or priority in your life, there will always be days when 
your motivation lags. Days when – despite all the progress you’ve made in the 
past – it just sounds easier to sit on the couch playing video</strong></div>

  <div class="main"><p>Let’s face it – no matter how excited you are about a
new project or priority in your life, there will always be days when your 
motivation lags. Days when – despite all the progress you’ve made in the past – 
it just sounds easier to sit on the couch playing video games than to buckle down 
and crank out the work needed to meet your goals. If you don't like your destiny, 
don't accept it.</p><p>Let’s face it – no matter how excited you are about a new 
project or priority in your life, there will always be days when your motivation 
lags. Days when – despite all the progress you’ve made in the past – it just 
sounds easier to sit on the couch playing video games than to buckle down and 
crank out the work needed to meet your goals. If you don't like your destiny, 
don't accept it.</p></div>

</div>
© www.soinside.com 2019 - 2024. All rights reserved.