简体   繁体   中英

CSS Designing Issue with UL and LI

I'm having an issue regarding the CSS while applying to the UL and LI Tag in HTML UI designing.

My CSS Code

 .jobs { list-style: none; }.jobs li { float: left; margin-left: 20px; padding: 10px; }.jobs::after { content: ""; display: grid; clear: both; }
 <ul class="jobs"> <div th:each="indTypeProduct:${indTypeProducts}"> <li> <div class="card" id="wrapper" style="align-items: center;"> <a href="#"><p th:text="${indTypeProduct}" /></a> </div> </li> <br> </div> </ul>

在此处输入图像描述

Could you please anyone help me on this issue?

Check the view source

Updated Code Please have a look and let me know where I'm going wrong and let me know, I simply want all my result should be align and have in same line.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Home</title>
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<link rel="stylesheet"
    href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
    integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
    crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<style type="text/css">

#wrapper {
    margin-left: 50px;
    margin-right: 20px;
    padding: 12px;
}

.card {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
    max-width: 300px;
    margin: auto;
    text-align: center;
    font-family: cursive;
}

.price {
    color: grey;
    font-size: 24px;
}

.card a {
    border: none;
    outline: 0;
    padding: 12px;
    color: white;
    background-color: #000;
    text-align: center;
    cursor: pointer;
    width: 100%;
    font-size: 18px;
    text-decoration: none;
}

.card a:hover {
    opacity: 0.5;
}
 
.jobs {
    list-style: none;
}

.jobs li {
    float: left;
    margin-left: 20px;
    padding: 10px;
}

.jobs::after {
    content: "";
    display: grid;
    clear: both;
}

</style>
</head>
<body>

    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <a class="navbar-brand" href="/home">Cart Studio</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false"
            aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active"><a class="nav-link" href="/home">Home
                        <span class="sr-only">(current)</span>
                </a></li>
                <li class="nav-item"><a class="nav-link" href="/product">Product</a>
                </li>
                <li class="nav-item"><a class="nav-link" href="/contact">Contact</a>
                </li>
                <li class="nav-item"><a class="nav-link" href="/profile">Profile</a>
                </li>
            </ul>

            <form class="form-inline my-2 my-lg-0">
                <input class="form-control mr-sm-2" type="search"
                    placeholder="Search" aria-label="Search">
                <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
            </form>
        </div>
    </nav>
    <br>
    <div>
        <h4>
            <p style="margin-left: 15px"> Hello test@gmail.com Greetings!!</p>
        </h4>
    </div>

    <hr style="color: black;">

    <div id="carouselExampleIndicators" class="carousel slide"
        data-ride="carousel">
        <ol class="carousel-indicators">
            <li data-target="#carouselExampleIndicators" data-slide-to="0"
                class="active"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
        </ol>
        <div class="carousel-inner">
            <div class="carousel-item active">
                <img class="d-block w-100" src="/uploads/images.jpg"
                    alt="First 1 slide" width="100" height="350">
            </div>
            <div class="carousel-item">
                <img class="d-block w-100" src="/uploads/images.jpg"
                    width="100" height="350" alt="Second slide">
            </div>
            <div class="carousel-item">
                <img class="d-block w-100" src="/uploads/images.jpg"
                    width="300" height="350" alt="Third slide">
            </div>
        </div>
        <a class="carousel-control-prev" href="#carouselExampleIndicators"
            role="button" data-slide="prev"> <span
            class="carousel-control-prev-icon" aria-hidden="true"></span> <span
            class="sr-only">Previous</span>
        </a> <a class="carousel-control-next" href="#carouselExampleIndicators"
            role="button" data-slide="next"> <span
            class="carousel-control-next-icon" aria-hidden="true"></span> <span
            class="sr-only">Next</span>
        </a>
    </div>

    <hr style="color: black;">

    <ul class="jobs">

        <div>

            <li>

                <div class="card" id="wrapper" style="align-items: center;">

                    <!-- <img th:src="@{/images/Mobile-Phones-Category.jpg}" alt="category" width="150" height="150"> -->

                    <a href="#"><p >retail</p></a>

                </div>
            </li>
             <br>
        </div>

        <div>

            <li>

                <div class="card" id="wrapper" style="align-items: center;">

                    <!-- <img th:src="@{/images/Mobile-Phones-Category.jpg}" alt="category" width="150" height="150"> -->

                    <a href="#"><p >mobile</p></a>

                </div>
            </li>
             <br>
        </div>
    </ul>

        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
            integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
            crossorigin="anonymous"></script>
        <script
            src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
            integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
            crossorigin="anonymous"></script>
        <script
            src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
            integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
            crossorigin="anonymous"></script>
</body>
</html>

One thing I have added here <ul class="row" style="width: 400px"> and it fixed the issue and width for not getting horizonatl scroll bar.

I'm having an issue regarding the CSS while applying to the UL and LI Tag in HTML UI designing.

My CSS Code

 .jobs { list-style: none; } .jobs li { float: left; margin-left: 20px; padding: 10px; } .jobs::after { content: ""; display: grid; clear: both; }
 <ul class="jobs"> <div th:each="indTypeProduct :${indTypeProducts}"> <li> <div class="card" id="wrapper" style="align-items: center;"> <a href="#"><p th:text="${indTypeProduct}" /></a> </div> </li> <br> </div> </ul>

在此处输入图片说明

Could you please anyone help me on this issue?

Check the view source

Updated Code Please have a look and let me know where I'm going wrong and let me know, I simply want all my result should be align and have in same line.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Home</title>
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<link rel="stylesheet"
    href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
    integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
    crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<style type="text/css">

#wrapper {
    margin-left: 50px;
    margin-right: 20px;
    padding: 12px;
}

.card {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
    max-width: 300px;
    margin: auto;
    text-align: center;
    font-family: cursive;
}

.price {
    color: grey;
    font-size: 24px;
}

.card a {
    border: none;
    outline: 0;
    padding: 12px;
    color: white;
    background-color: #000;
    text-align: center;
    cursor: pointer;
    width: 100%;
    font-size: 18px;
    text-decoration: none;
}

.card a:hover {
    opacity: 0.5;
}
 
.jobs {
    list-style: none;
}

.jobs li {
    float: left;
    margin-left: 20px;
    padding: 10px;
}

.jobs::after {
    content: "";
    display: grid;
    clear: both;
}

</style>
</head>
<body>

    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <a class="navbar-brand" href="/home">Cart Studio</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false"
            aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active"><a class="nav-link" href="/home">Home
                        <span class="sr-only">(current)</span>
                </a></li>
                <li class="nav-item"><a class="nav-link" href="/product">Product</a>
                </li>
                <li class="nav-item"><a class="nav-link" href="/contact">Contact</a>
                </li>
                <li class="nav-item"><a class="nav-link" href="/profile">Profile</a>
                </li>
            </ul>

            <form class="form-inline my-2 my-lg-0">
                <input class="form-control mr-sm-2" type="search"
                    placeholder="Search" aria-label="Search">
                <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
            </form>
        </div>
    </nav>
    <br>
    <div>
        <h4>
            <p style="margin-left: 15px"> Hello test@gmail.com Greetings!!</p>
        </h4>
    </div>

    <hr style="color: black;">

    <div id="carouselExampleIndicators" class="carousel slide"
        data-ride="carousel">
        <ol class="carousel-indicators">
            <li data-target="#carouselExampleIndicators" data-slide-to="0"
                class="active"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
        </ol>
        <div class="carousel-inner">
            <div class="carousel-item active">
                <img class="d-block w-100" src="/uploads/images.jpg"
                    alt="First 1 slide" width="100" height="350">
            </div>
            <div class="carousel-item">
                <img class="d-block w-100" src="/uploads/images.jpg"
                    width="100" height="350" alt="Second slide">
            </div>
            <div class="carousel-item">
                <img class="d-block w-100" src="/uploads/images.jpg"
                    width="300" height="350" alt="Third slide">
            </div>
        </div>
        <a class="carousel-control-prev" href="#carouselExampleIndicators"
            role="button" data-slide="prev"> <span
            class="carousel-control-prev-icon" aria-hidden="true"></span> <span
            class="sr-only">Previous</span>
        </a> <a class="carousel-control-next" href="#carouselExampleIndicators"
            role="button" data-slide="next"> <span
            class="carousel-control-next-icon" aria-hidden="true"></span> <span
            class="sr-only">Next</span>
        </a>
    </div>

    <hr style="color: black;">

    <ul class="jobs">

        <div>

            <li>

                <div class="card" id="wrapper" style="align-items: center;">

                    <!-- <img th:src="@{/images/Mobile-Phones-Category.jpg}" alt="category" width="150" height="150"> -->

                    <a href="#"><p >retail</p></a>

                </div>
            </li>
             <br>
        </div>

        <div>

            <li>

                <div class="card" id="wrapper" style="align-items: center;">

                    <!-- <img th:src="@{/images/Mobile-Phones-Category.jpg}" alt="category" width="150" height="150"> -->

                    <a href="#"><p >mobile</p></a>

                </div>
            </li>
             <br>
        </div>
    </ul>

        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
            integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
            crossorigin="anonymous"></script>
        <script
            src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
            integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
            crossorigin="anonymous"></script>
        <script
            src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
            integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
            crossorigin="anonymous"></script>
</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM