Skip to content

Custom HTML and CSS Rendered differently on Magento page

I have created the custom HTML and CSS banner for magento page. On localhost it is showing as below:
enter image description here

On magento localhost is showing as below:

enter image description here

below is code of banner in localhost

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="./styles.css">
    <title>Hello, world!</title>
  </head>
  <body>
 
    <div class="img-box">
        <div class="cat-banner-info-box">
            <!-- Spotlight Box -->
            <div id="cat-spotlight-box">
                <p class="cat-spotlight-box-text">wedding</p>
            </div>
            <!-- Category banner Title-->
            <h3 id="cat-banner-title">
                <a href="#">One more for the guest list</a>
            </h3>
            <!-- Category banner description -->
            <p id="cat-banner-description">
                Lorem ipsum dolor sit amet consectetur adipisicing elit. Corrupti, earum!
            </p>
            <!-- Shop Now Link -->
            <p id="cat-banner-shop-now">
                <a href="#">shop now</a>
            </p>
        </div>
        <div class="cat-img-box">
            <a href="#">
                <img src="./media/images/fashion-jewellery.jpeg" alt="" class="cat-img">
            </a>            
        </div>
        
    </div>
    
    

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </body>
</html>

CSS for above code as follows:

/* Details Box */
.cat-banner-info-box{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items:flex-start;
    padding-left: 65px;
    position:relative;
    flex-wrap: nowrap;
    flex-grow: 0;
}

#cat-spotlight-box {
    background-color: #545454;
    width: 127px;
    padding: 0 20px;
    height: 31px;
    z-index: 1;
}

.cat-spotlight-box-text {
    font-family: Din Regular,HelveticaNeue-bold,Helvetica Neue bold,Helvetica Neue,Helvetica,"sans-serif";
    font-size: 15px;
    color: #ffe256;
    display: flex;
    text-transform: uppercase;
    position: relative;
}

#cat-banner-title {
    font-family: avalondemi,HelveticaNeue-regular,Helvetica Neue regular,Helvetica Neue,Helvetica,Arial,"sans-serif";
    color: #212121;
    padding-top: 10px;
    margin: 10px 0;
}

#cat-banner-title a {
    color: #212121;
    text-decoration: none;
    background-color: transparent;
    margin: 10px 0;
}

#cat-banner-description {
    display: block;
    font-family: Din Light,HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,"sans-serif";
    text-transform: none;
    padding-top: 4px;
    color: #151515;
    width: 70%;
}

#cat-banner-shop-now a{
    cursor: pointer;
    text-decoration: underline;
    text-transform: uppercase;
    color: #151515;
    letter-spacing: 1.4px;
    display: inline-block;
}

#cat-banner-shop-now a:hover {
    font-weight: bold;
}

.cat-banner-image-container img {
    display: block;
    /* object-fit: fill; */
    width: 100%;
    height: auto;
}

.img-box {
    width:100%;
    height: auto;
    border-top: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    flex-direction: row;

}

.cat-img {
    display: block;
    position: relative;
}

.cat-img-box {
    display: flex;
    float: right;
}


@media (min-width: 0) {
.img-box {
    flex-direction: column-reverse;
    justify-content: center;
}
.cat-banner-info-box {
    margin-top: -10px;
}
}


@media (min-width: 768px) {
    .img-box {
        flex-direction: row;
        justify-content: space-between;
    }
    .cat-img {
        width: 525px;
        height: auto;
    }
}

@media (min-width: 992px) {
    .img-box {
        flex-direction: row;
        justify-content: space-between;
    }
    .img-box img {
        width:620px;
        height: auto;
    }
}

@media (min-width: 1366px) {
    .img-box img {
        width:877px;
        height: auto;
    }
    .img-box {
        justify-content: center;
    }
}

And below code, I copied as html element in magento cms.

<style>
    
/* Details Box */
.cat-banner-info-box{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items:flex-start;
    padding-left: 65px;
    position:relative;
    flex-wrap: nowrap;
    flex-grow: 0;
}

#cat-spotlight-box {
    background-color: #545454;
    width: 127px;
    padding: 0 20px;
    height: 31px;
    z-index: 1;
}

.cat-spotlight-box-text {
    font-family: Din Regular,HelveticaNeue-bold,Helvetica Neue bold,Helvetica Neue,Helvetica,"sans-serif";
    font-size: 15px;
    color: #ffe256;
    display: flex;
    text-transform: uppercase;
    position: relative;
}

#cat-banner-title {
    font-family: avalondemi,HelveticaNeue-regular,Helvetica Neue regular,Helvetica Neue,Helvetica,Arial,"sans-serif";
    color: #212121;
    padding-top: 10px;
    margin: 10px 0;
}

#cat-banner-title a {
    color: #212121;
    text-decoration: none;
    background-color: transparent;
    margin: 10px 0;
}

#cat-banner-description {
    display: block;
    font-family: Din Light,HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,"sans-serif";
    text-transform: none;
    padding-top: 4px;
    color: #151515;
    width: 70%;
}

#cat-banner-shop-now a{
    cursor: pointer;
    text-decoration: underline;
    text-transform: uppercase;
    color: #151515;
    letter-spacing: 1.4px;
    display: inline-block;
}

#cat-banner-shop-now a:hover {
    font-weight: bold;
}

.cat-banner-image-container img {
    display: block;
    /* object-fit: fill; */
    width: 100%;
    height: auto;
}

.img-box {
    width:100%;
    height: auto;
    border-top: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    flex-direction: row;

}

.cat-img {
    display: block;
    position: relative;
}

.cat-img-box {
    display: flex;
    float: right;
}


@media (min-width: 0) {
.img-box {
    flex-direction: column-reverse;
    justify-content: center;
}
.cat-banner-info-box {
    margin-top: -10px;
}
}


@media (min-width: 768px) {
    .img-box {
        flex-direction: row;
        justify-content: space-between;
    }
    .cat-img {
        width: 525px;
        height: auto;
    }
}

@media (min-width: 992px) {
    .img-box {
        flex-direction: row;
        justify-content: space-between;
    }
    .img-box img {
        width:620px;
        height: auto;
    }
}

@media (min-width: 1366px) {
    .img-box img {
        width:877px;
        height: auto;
    }
    .img-box {
        justify-content: center;
    }
}
</style>


        <div class="img-box">
            <div class="cat-banner-info-box">
                <!-- Spotlight Box -->
                <div id="cat-spotlight-box">
                    <p class="cat-spotlight-box-text">wedding</p>
                </div>
                <!-- Category banner Title-->
                <h3 id="cat-banner-title">
                    <a href="#">One more for the guest list</a>
                </h3>
                <!-- Category banner description -->
                <p id="cat-banner-description">
                    Lorem ipsum dolor sit amet consectetur adipisicing elit. Corrupti, earum!
                </p>
                <!-- Shop Now Link -->
                <p id="cat-banner-shop-now">
                    <a href="#">shop now</a>
                </p>
            </div>
            <img src="{{media url=wysiwygkatiecategory-pagesimagesfashion-jewellery.jpeg}}" alt="" class="cat-img">
        </div>
   

Can anyone tell me what went wrong??