Nick Nick -4 years ago 82
CSS Question

AngularJS - Repeated P tags not wrapping correctly

I've developed an array of different skills in angular which are showing up fine and wrapping correctly on the desktop version of my site, but on smaller screens, the items are ignoring the container's padding and width and failing to wrap always at the same point.

Ironically, where the object 'Responsive Design' from the array is displayed in the list, it will not wrap the word 'Responsive', so this always pushes past the width of the container, and the word 'Design' correctly wraps on to a new line.

Codepen: http://codepen.io/nickwcook/full/KWePVx/.

HTML:

<section id="about" ng-controller="skillsController">

<div class="sectionContent">

<div id="bio">

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

<div id="skillsList">

<p>My skills include:</p>

<p ng-repeat="skill in skills" class="skillItem">{{skill.name}}.</p>

</div>

</div>

</div>

</section>


CSS:

section
{
display: block;
margin: 0;
background: transparent;
z-index: 90;
}

.sectionContent
{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 100px 30px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}

/* ABOUT SECTION */

#about .sectionContent > div
{
width: 100%;
padding: 0 15%;
}

#about p
{
line-height: 26px;
text-align: center;
}

#about #skillsList
{
text-align: center;
margin-top: 50px;
}

#about #skillsList p:first-of-type
{
margin-bottom: 10px;
}

#about #skillsList p.skillItem
{
display: inline;
margin: 0 15px;
}

Answer Source

Change This

#about #skillsList p.skillItem {
  display: inline;
  margin: 0 15px;
}

to this

#about #skillsList p.skillItem {
  display: inline-block; 
  margin: 0 15px;
}

-- That will fix your layout, but my recommendation is that you move from the P element to using the List ( ul > li ) for a more semantic approach.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download