Search code examples
htmlcsstwitter-bootstraphorizontal-scrolling

how prevent horizontal scroll in bootstrap and list?


I have a responsive UL List , many Li ImageItem and span are in this Ul. on maximize size 3 item shows in one row and when I resize ( small) my browser, 2 item shows and it works fine. But in smallest size of my browser horizontal scroll appear :( 1 item shows but scroll appear, how I can prevent horizontal scroll?! this is my css :

.myUl {
    font-size:large !important;
    color:#373636 !important;
    text-align:center !important;
}
.myUl li {
    width:350px !important;
}
.myUl li:hover {
    background:rgba(0, 0, 0, 0.2) !important;
}
.myUl li img {
    height:170px !important;
    width:100px !important;
}
.myUl li span {
    float:right !important;
    width:170px;
    padding-right:8px !important;
    padding-top:10px !important;
    text-align:right !important;
    vertical-align:middle !important;
    line-height: 1.5em !important;
}
ul.img-list {
    list-style-type: none;
    margin: 0;
    padding: 0;
    text-align: center;
}
ul.img-list li {
    display: inline-block;
    height: 180px;
    margin: 0 1em 1em 0;
    position: relative;
    width: 150px;
}
ul.img-list li:hover span.text-content {
    opacity: 1;
}

this is my Index.cshtml

<div>
    <ul class="img-list myUl">
        <li>
            <span>
                some text here
            </span>
            <span style="float: left !important; padding-top: 3px !important;">
                <a>
                    <img class="img-responsive img-circle img-thumbnail" src="~/Images/MenuImages/z.jpg"  />
                </a>
            </span>
        </li>
        <li>
           .........
        </li>
  </ul>

an image of my page


Solution

  • To prevent horizontal scrolling just add this to your body tag in Css like such :

    body {
        overflow-x: hidden;
    }
    

    Hope this helped