2014-10-28 3 views
0

Я делаю сайт с использованием гибкой модели коробки. Я пытаюсь, чтобы текст был выровнен справа от изображения, а затем под изображением. Я попробовал Float: справа/слева и align = "влево/вправо", и они просто заставляют изображение исчезать. Это из-за гибкой модели коробки? Вот исходный код. Статья является примером использования с веб-сайта World of Tanks.html текст обертывание вокруг изображения

<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 почему часть статьи была отделена от кода. Вот 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; 

} 

Спасибо за помощь. Извините за плохое форматирование, это мой первый пост здесь

+1

** Это не имеет ничего общего с спецификациями flexbox **. Если вы хотите, чтобы текст обертывался вокруг элемента с плавающей точкой (например, изображение), и текст, и элемент должны быть братьями и сестрами. Другими словами, вы должны перенести изображение в элемент '

', чтобы обернуть вокруг него текст. – Terry

ответ

0

Ящик webkit - это то, что отбрасывает его ... семантически помещая его внутри статьи, это правильный путь.

Это прекрасно работает: 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; 

} 
+0

Спасибо за помощь! – Fusive

+0

@Fusive - похоже, что вы используете устаревшую устаревшую спецификацию flexbox. [Вот список поддержки браузера] (http://caniuse.com/#feat=flexbox). Последние версии браузеров (и многие другие версии) поддерживают новую спецификацию Flexbox. – misterManSam

+0

Я знаю ... Я учусь из учебников HTML 5 от thenewboston, они с 2011 года (я думаю). Мне нужно изучить обновленную модель. Есть ли какое-либо место, которое показывает, что было устаревшим, или мне нужно все это изучить с нуля. Редактировать: Спасибо за ссылку. – Fusive

0

Я думаю, что вы забыли о закрытии </div> вашего info-p DIV, а затем вы можете просто добавить float: left к ней, и она работает.

См. demo.

Смежные вопросы