0

Pls how can i display my li elements in a horizontal direction, i want the li element to contain an image and a text that will display on the image, i tried everything but the li element is just displaying vertically

here is my home.page.scss page

ul {
    width: 100% !important;
    list-style-type: none !important;
    margin: auto !important; 
    overflow-x: auto !important;
    white-space: nowrap !important;
}
li{
    display: inline !important;
}
.deyDiv{
    position: relative;
    margin-top:5px;
    margin-bottom:5px;
    padding-right:2px; 
}
.text{
    position: absolute;
    bottom: 8px;
    left: 16px;
}
.iuyE{ 
    border-radius:10px;
}
.news{
    width:60%; 
    height:45%;
}

here's the home.page.html page

    <ul >
        <li *ngFor="let video of discovrys">
            <div class="deyDiv news">
                <img class="iuyE" [src]="image">
                <h6 class="text">The title of the nese</h6>
            </div>
        </li>
    </ul>   

Pls what am i doing that's wrong

Eloike David
  • 175
  • 4
  • 15
  • Can you create a demo where it reproduces your issue? Right now the code provides a blank output. – m4n0 Aug 20 '20 at 14:11
  • You want the text to be at the bottom of the image ? Or you want the `li` to be displayed horizontally instead of vertically ? – Emilien Aug 20 '20 at 14:13
  • @Emilien i want the both the horizontal display of the images and the text to display at the bottom of the image – Eloike David Aug 20 '20 at 14:19

4 Answers4

2

You could replace

li {
  display: inline !important;
}

with

li {
  display: inline-block;
}

Difference b/n them here. Also try to use !important as sparingly as possible.

Working example: Stackblitz

ruth
  • 29,535
  • 4
  • 30
  • 57
0

try this:

ul {
    display: flex;
}
shinjw
  • 3,329
  • 3
  • 21
  • 42
Ehsan
  • 766
  • 10
  • 17
0

You will be able to do it using flexbox.

ul {
  display: flex;
  flex-direction: row;
}

li {
  flex: 1;
}

.deyDiv {
  display: flex;
  flex-direction: column;
}
Emilien
  • 2,701
  • 4
  • 15
  • 25
0

Your approach to the li list is correct using

display: inline;

However inside of every li item you are using a div element which by default uses

display: block;

change the display from the class news to either inline or inline-block,
working code: https://jsfiddle.net/6w5ohxsL/1/