I am trying to keep some image in a single row. I am using bootstrap and image also including responsive class.
After 12 image new row has create for the rest of the image. But I want all image keep in a single row.
I have my code in this format
<ul class="people">
<li><a><img ></a>
<li><a><img ></a>
</ul>
Any kind of help will be appreciated. Thanks
After 12 image new row has create for the rest of the image. But I
want all image keep in a single row.
These images stays in a single row no matter how many.
.people li {
display: inline;
white-space: nowrap
}
<ul class="people">
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
<li><a><img src="http://lorempixel.com/100/100/sports" ></a>
</ul>
The simplest way in twitter-bootstrap is the class row whit div
<div class="row">
<div><a><img src='your_img_1' ></a></div>
<div><a><img src='your_img_2'></a></div>
<div><a><img src='your_img_3'></a></div>
</div>
Or If you need the image in <ul class="list-inline"> you need an inline block style
or for img
img {
border: 0 none;
display: inline-block;
height: auto;
max-width: 100%;
vertical-align: middle;
}
Please take a look at this Plunker.
HTML code:
<ul class="people">
<li>
<a><img src="http://blue-engineering.nl/wp-content/uploads/2014/10/Slider-blue.png"></a>
</li>
<li>
<a><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Red_flag.svg/2000px-Red_flag.svg.png"></a>
</li>
</ul>
CSS code:
img{
width: 50px;
height: 50px;
}
li{
display: inline-block;
list-style-type: none;
}
Hope this is what you asked for :)
Try this :
li{
display: inline-block;
}
You may use display or float code for this.
Example:
li{
display:inline-block;
}
OR
li{
float:left;
}
But its better to use display code. because if you want to use float code, then you need to add a clear code after finish floating..
Example:
<ul class="people">
<li><a><img ></a>
<li><a><img ></a>
</ul>
<div class="people2">
your stuff... here
</div>
CSS
li{
float:left;
}
.people2 {
clear:both
}
So... I think its better to use display:inline-block
You can use
li
{
display:inline-block;
}
After 12 image new row has create for the rest of the image
li:nth-child(12n)
{
clear:both;
}
Related
I'm pretty new to css and my navbar looks really bad. I'm trying to play with the css but i get nothing better than the below picture. If i remove the .menu, icons get verticaly aligned;
Of course i've seen a lot of stackoverflow post on this topic and tryied lot of stuff, but again, could not get better than the below picture.
Here my react html code.
<ul className="menu">
<li>
<a href="https://discord.com/channels/#me" id="menu-item-41">
<img src={Discord} alt="discord" className="discord-logo"/>
</a>
</li>
<li>
<a href="www.twitter.com" className="page-scroll" id="menu-item-42">
<img src={Twitter} alt="twitter" className="twitter-logo"/>
</a>
</li>
<li>
<a href="#" className="page-scroll" id="menu-item-44">
TAG
</a>
</li>
<li>
<a href="#roadmap-title" className="page-scroll" id="menu-item-43">
ROAD MAP
</a>
</li>
<li>
<a href="#team" className="page-scroll" id="menu-item-45">
TAG2
</a>
</li>
<li>
<button onClick={() => this.connect() }
id="menu-item-47"
className="connect-button">CONNECT
</button>
</li>
</ul>
Here my css :
li.menu-item {
margin-bottom: 40px;
vertical-align: middle;
text-align: center;
}
.menu{
position: left;
display: inline-flex;
text-align: center;
vertical-align: middle;
float: left;
margin: 40;
}
Eny suggestions or observation would be super welcomed !
Try changing your css to this
.menu {
display: flex;
justify-content: space-between;
align-items: center;
}
I have this list and I want to show this inline , I use list-inline class, but the result is not true .
I don't know why this happened . Thanks for any answer .
cshtml code :
<ul style="text-align: center; list-style-type: none; vertical-align: top;">
<li>
#foreach (var item in Model.SocialNetworks)
{
<ul class="list-inline" style="text-align:center;list-style-type:none;padding-top:15px;">
<li class="col-xs-3">
<a class="aFooter" href="#item.SocialLink">
<img class="img-responsive center-block socialIcon" src="#Url.Content(item.SocialIcon.ToString())" />
</a>
</li>
</ul>
}
</li>
</ul>
Result :
Remove the padding-top: 15px; at the inside <li> tag.
With running fiddle.
Try float left to li element
ie, li{ float: left;}
Basically, the navbar works perfectly, it stays statically stuck to the top of the screen when the user scrolls. When it is text-only, everything works fine. When I want to add the Twitter and Facebook icons, I can simply do so and it will work. However, as soon as I add an <a href="#"> to enclose the image, it breaks completely. Occasionally, the navbar will work even with the image links, but around 90% of the time it will simply fail, the navbar will not appear, and even though Inspect Element reveals that it should be loaded, nothing is shown.
Relevant:
Working HTML
<div class="" id="header">
<ul class="menu">
<li class="menu-item first">Gallery</li>
<li class="menu-item second">Charity</li>
<li class="menu-item third">About Me</li>
<li class="menu-item fourth">Contact</li>
<li class="menu-item media"><img src="TaiwanSite_files/twitter.png" height="25">
<img src="TaiwanSite_files/fb.png" height="25"></li>
<li class="menu-top">
<img src="TaiwanSite_files/top-arrow.svg" height="61" width="61">
</li>
</ul>
</div>
Broken HTML
<div class="" id="header">
<ul class="menu">
<li class="menu-item first">Gallery</li>
<li class="menu-item second">Charity</li>
<li class="menu-item third">About Me</li>
<li class="menu-item fourth">Contact</li>
<li class="menu-item media"><img src="TaiwanSite_files/twitter.png" height="25">
<img src="TaiwanSite_files/fb.png" height="25"></li>
<li class="menu-top">
<img src="TaiwanSite_files/top-arrow.svg" height="61" width="61">
</li>
</ul>
</div>
The relevant CSS:
.menu {
padding:0;margin:0 auto;position:relative;max-width:1024px;height:2.4em;padding-left:62px;padding-right:62px
}
.menu:after {
display:block;content:"";clear:both
}
.menu-logo {
position:absolute;top:.18em;left:0;right:0;text-align:center;z-index:-1
}
.menu-logo img {
width:4.8em;margin:0;padding:0
}
.menu-item {
display:block;float:left;min-width:20%;text-align:right;height:1.2em;margin-top:.58em
}
.menu-item.first {
text-align:left
}
.menu-item.second {
text-align:left
}
.menu-item.third {
text-align:left
}
.menu-item.fourth {
text-align:left
}
.menu-item.media {
float:right;text-align:right
}
.menu-item a {
text-decoration:inherit;font-family:inherit;color:inherit;font-weight:inherit;line-height:inherit;display:none
}
If there is any additional information I can provide at this time, please inform me and I will try my best to do so. Thank you very much in advance for your time and assistance.
Add a special class to your a tags (in this case on):
<a class="on" href="https://twitter.com/">
<img src="TaiwanSite_files/twitter.png" height="25"></a>
<a class="on" href="https://facebook.com/">
<img src="TaiwanSite_files/fb.png" height="25"></a>
Then add this to your styling:
.on {
display: inline-block !important;
}
for the images to display side-by-side, or this:
.on {
display: block !important;
}
for the images to be one on top of the other.
This should help.
I have an unordered list of items where each item is an image followed by some text. I would like the text to line up exactly, but due to the icons being slightly different sizes, the text of each is not aligned. See the JSFiddle below for an example. You can see the "O" of Option is further to the left than the "R" of RSS feed.
What is the easiest way of achieving this? Is there a way to do this WITHOUT changing the images?
This is my HTML:
<ul class="dropdown-menu">
<li><a id="login" style="cursor:pointer;"><img src="http://www.w3schools.com/images/up.gif" /> Login</a></li>
<li><a id="upload" style="cursor:pointer;"><img src="http://static.bbci.co.uk/id/0.23.4/img/bbcid_orb_signin_dark.png" /> Upload a file</a></li>
<li><a id="option 3" style="cursor:pointer;"><img src="http://res2.windows.microsoft.com/resbox/en/windows%207/main/4f6cbd09-148c-4dd8-b1f2-48f232a2fd33_818.jpg"/>Option 3</a></li>
<li><a id="rss" id="rss" ><img src="http://www.w3schools.com/images/up.gif" /> RSS Feed</a></li>
<li><a id="about" style="cursor:pointer;"><img src="https://www.google.com/images/icons/product/googlemail-16.png" /> About</a></li>
</ul>
There is a JSFiddle here:
http://jsfiddle.net/9f1gxLv6/
Thanks,
Phil
If you're looking to space the icons and text evenly horizontally I recommend using the images as backgrounds instead of inline, then adding some padding:
#login {
background-image: url('http://www.w3schools.com/images/up.gif');
}
#upload {
background-image: url('http://static.bbci.co.uk/id/0.23.4/img/bbcid_orb_signin_dark.png');
}
#option_3 {
background-image: url('http://res2.windows.microsoft.com/resbox/en/windows%207/main/4f6cbd09-148c-4dd8-b1f2-48f232a2fd33_818.jpg');
}
#rss {
background-image: url('http://www.w3schools.com/images/up.gif');
}
#about {
background-image: url('https://www.google.com/images/icons/product/googlemail-16.png');
}
a {
display:inline-block;
padding: 2px 0 2px 30px;
background-repeat:no-repeat;
background-position: left center;
}
<ul class="dropdown-menu">
<li><a id="login" style="cursor:pointer;">Login</a>
</li>
<li><a id="upload" style="cursor:pointer;">Upload a file</a>
</li>
<li><a id="option_3" style="cursor:pointer;">Option 3</a>
</li>
<li><a id="rss" id="rss">RSS Feed</a>
</li>
<li><a id="about" style="cursor:pointer;">About</a>
</li>
</ul>
I'm trying to add a few images to my site but for some reason vertical bars are showing under and to the right of the images.
Here's my website URL: http://bit.ly/Lcspfp
The problem images are the brand logos at the bottom of the page.
Here's the code im using to display the brand logos:
<ul id="brands">
<li><a><img src="images/brand1.png" alt="" /></a></li>
<li><a><img src="images/brand2.png" alt="" /></a></li>
<li><a><img src="images/brand3.png" alt="" /></a></li>
<li><a><img src="images/brand4.png" alt="" /></a></li>
<li><a><img src="images/brand5.png" alt="" /></a></li>
<li><a><img src="images/brand6.png" alt="" /></a></li>
<li class="last"></li><p>
</ul>
Here's an image of the images with the vertical bars that I dont want there: http://i.imgur.com/9g1do.png
Add this CSS rule:
ul#brands a {
background:none;
}
Change line 644 of your styles.css file to the following:
.footer ul a { padding-right:5px; margin-right:3px; }
Delete this CSS-rule :
background: url(../images/links_separator.gif) no-repeat 100% 50%;
It creates those vertical lines.