Reputation: 6040
I am really struggling to get a image to display inline with unordered list.
HTML:
<div class="customer-indiv man">
<a class="customer_thumb" href="/fan/332profile.com">
<img src="http://i.imgur.com/WiAvs8Q.jpg"/>
</a>
<ul>
<li><a href="/fan/332profile.com">name of user</a></li>
<li>phone no</li>
<li>text</li>
</ul>
</div>
CSS:
.customer_thumb {
display: inline-block;
}
.customer-indiv {
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
padding: .8em 0;
}
.customer-indiv:nth-child(4) {
border-bottom: 0;
padding-bottom: 0;
}
.customer-indiv:first-child {
padding-top: 0;
}
I'd like it to be displayed, with the image to the left and the 3 li's to the right, which I believe is what my CSS should do. Like so:
name
IMAGE phone no
text
Unfortunately, at the moment it outputs:
IMAGE
name
phone no
text
Upvotes: 1
Views: 337
Reputation: 78676
There are few ways to achieve that:
.customer-indiv {
display: flex;
align-items: center;
}
.customer_thumb img {
display: block;
max-width: 100px;
height: auto;
}
<div class="customer-indiv man">
<a class="customer_thumb" href="/fan/332profile.com">
<img src="http://i.imgur.com/WiAvs8Q.jpg" />
</a>
<ul>
<li><a href="/fan/332profile.com">name of user</a></li>
<li>phone no</li>
<li>text</li>
</ul>
</div>
.customer-indiv {
display: table;
}
.customer-indiv > a,
.customer-indiv > ul {
display: table-cell;
vertical-align: middle;
}
.customer_thumb img {
display: block;
max-width: 100px;
height: auto;
}
<div class="customer-indiv man">
<a class="customer_thumb" href="/fan/332profile.com">
<img src="http://i.imgur.com/WiAvs8Q.jpg" />
</a>
<ul>
<li><a href="/fan/332profile.com">name of user</a></li>
<li>phone no</li>
<li>text</li>
</ul>
</div>
.customer-indiv {
font-size: 0; /*remove whitespace*/
}
.customer-indiv > a,
.customer-indiv > ul {
font-size: 16px;
display: inline-block;
vertical-align: middle;
}
.customer_thumb img {
display: block;
max-width: 100px;
height: auto;
}
<div class="customer-indiv man">
<a class="customer_thumb" href="/fan/332profile.com">
<img src="http://i.imgur.com/WiAvs8Q.jpg" />
</a>
<ul>
<li><a href="/fan/332profile.com">name of user</a></li>
<li>phone no</li>
<li>text</li>
</ul>
</div>
Upvotes: 1
Reputation: 8537
You can do it like this :
CSS :
.customer_thumb img { max-width: 50px; display: inline-block; vertical-align: top; }
ul { display: inline-block; vertical-align: top; margin: 0; }
Upvotes: 0