简体   繁体   English

HTML文字环绕图像

[英]Html text wrapping around image

I am making a website using the flexible box model. 我正在使用弹性盒模型制作网站。 I am trying to have the text be aligned to the right of the image, and then below the image. 我正在尝试使文本在图像的右边,然后在图像的下面对齐。 I tried the Float:right/left and the align="left/right" and they just make the image disappear. 我尝试了Float:right / left和align =“ left / right”,它们只是使图像消失了。 Is this because of the flexible box model? 这是因为采用了灵活的包装盒型号吗? Here is the source code. 这是源代码。 The article is an example im using from the World of Tanks website. 本文是《战车世界》网站上使用的示例。

<div id="content">
    <section id="section">
        <div id="title">
            <h1>This is the Title</h1>
        </div>
        <div id="info-p">
            <div id="photo">
                <img id="img" src="400x300.png">
            </div>
        <article id="info">
            <p>
                US Army tankers, by late March 1945, when the final surge into Germany began, were among the most savvy graduates of the school of war. They knew how to storm cities and deal with small groups of defenders in villages or at crossroads. They could slog through fortifications and run like the cavalry of old. By and large, they had worked out effective teamwork strategies with the infantry, tank destroyers, and artillery, even if still a bit ambivalent about their friends in the fighter-bombers above them. They had learned to beat better tanks and worked out a series of pragmatic technical solutions to problems ranging from communication to moving on ice.

The German Army fought on like a body without a brain—OKW records show it was often a couple days behind developments on the battlefield, and headquarters at all levels had difficulty delivering orders to units that often existed only on paper. Lt. Gen. George Patton’s G-2 shop estimated that as of March 17, total German tank strength on the western front amounted to the equivalent of a single full-strength panzer division.1 As of March 31, the entire force of panzers and assault guns in Third Army’s sector was estimated at only 55 vehicles, all opposite XX Corps in the Fulda area.2

Cornelius Ryan captured the essence of the final push: “The race was on. Never in the history of warfare had so many men moved so fast. The speed of the Anglo-American offensive was contagious, and all along the front, the drive was taking on the proportions of a giant contest.”3 So fast, indeed; between April 24 and 30, the 737th Tank Battalion moved 520 miles.4

The Ninth Army pounded in the direction of Berlin all the way to the Elbe River. Just to the    south, First Army advanced to the Mulde River. Patton’s Third Army drove toward Czechoslovakia, and Seventh Army pushed through Bavaria toward the rumored Nazi National Redoubt in the Bavarian Alps and Austria.5

The tankers rolled past columns of German POWs heading for the rear, often with no supervision.     Increasingly, displaced persons and released Allied POWs also appeared.
            </p>
        </article>

    </section>


</div>

IDK why some of the article was separated from the code. IDK为什么将某些文章与代码分开。 Here is the CSS 这是CSS

#section{
font: 14px Trebuchet MS;
}
#title{
text-align:left;
display:-webkit-box;
-webkit-box-pack:left;
padding:5px;
margin:10px;
}
#info-p{
display:-webkit-box;
-webkit-box-pack:left;
padding:5px;
margin:10px;
}
#photo{


}
#info{
display:-webkit-box;
-webkit-box-pack:left;
-webkit-box-flex:1;
padding:5px;
margin:10px;
max-width:800px;

}

Thanks for the help. 谢谢您的帮助。 Sorry for the bad formatting, this is my first post here 不好意思,这是我的第一篇文章

The webkit box is what is throwing it off...semantically putting it inside the article is the right way to go, though. webkit框是使它掉落的东西……尽管如此,将其放入文章中是正确的方法。

This works fine: http://jsfiddle.net/34u4bhkh/ 效果很好: http//jsfiddle.net/34u4bhkh/

#section{
font: 14px Trebuchet MS;
}
#title{
text-align:left;
display:-webkit-box;
-webkit-box-pack:left;
padding:5px;
margin:10px;
}
#info-p{
padding:5px;
margin:10px;
}
#photo{
float:right;
    margin-left:5px;
    margin-bottom:5px;

}
#info{
padding:5px;
margin:10px;
max-width:800px;

}

I think you forgot the closing </div> of your info-p div, and then you can just add float: left to it, and it works. 我认为您忘记了info-p div的结束</div> ,然后只需在其中添加float: left就可以了。

See the demo . 参见演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM