Harvey
Harvey

Reputation: 3

Moving img position

So here's my img

CURRENT POSITION

enter image description here

and i'm wondering if i can move the images position

to this

enter image description here

i tried to use position:absolute with, top bottom right left adjustments but still not work.

<div id="myCarousel" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                <li data-target="#myCarousel" data-slide-to="1"></li>
                <li data-target="#myCarousel" data-slide-to="1"></li>
            </ol>

            <div class="carousel-inner">
                <div class="item active" style="height: 320px;"> 
                    <img src="./img/flat1.jpg" alt="flat1" style="width: 100%;">
                        <div class="carousel-caption">
                            <h3>This is flat</h3>
                            <p>flat wallpaper</p>
                        </div>
                </div>
                <div class="item" style="height: 320px;">
                    <img src="./img/flat2.jpg" alt="flat2" style="width: 100%;">
                        <div class="carousel-caption">
                            <h3>This is flat wallpaper</h3>
                                <p>This is During summer</p>
                        </div>
                </div>
                <div class="item" style="height: 320px;">
                    <img src="./img/flat3.jpg" alt="flat3" style="width: 100%;">
                        <div class="carousel-caption">
                            <h3>Bora</h3>
                                <p>During Day time</p>
                        </div>
                </div>
            </div>

            <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left"></span>
                <span class="sr-only">Previous</span>
            </a>    
            <a class="right carousel-control" href="#myCarousel" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>

Upvotes: 0

Views: 138

Answers (1)

Rocks
Rocks

Reputation: 1155

You can use position:relative with a negative top value to get the result you are looking for.

.item img {
  position: relative;
  top: -120px;
}
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

</head>
<body>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                <li data-target="#myCarousel" data-slide-to="1"></li>
                <li data-target="#myCarousel" data-slide-to="1"></li>
            </ol>

            <div class="carousel-inner">
                <div class="item active" style="height: 200px;"> 
                    <img src="http://theartmad.com/wp-content/uploads/2015/09/Best-Desktop-Background-1.jpg" alt="flat1" style="width: 100%;">
                        <div class="carousel-caption">
                            <h3>This is flat</h3>
                            <p>flat wallpaper</p>
                        </div>
                </div>
                <div class="item" style="height: 200px;">
                    <img src="http://theartmad.com/wp-content/uploads/2015/09/Best-Desktop-Background-1.jpg" alt="flat2" style="width: 100%;">
                        <div class="carousel-caption">
                            <h3>This is flat wallpaper</h3>
                                <p>This is During summer</p>
                        </div>
                </div>
                <div class="item" style="height: 200px;">
                    <img src="http://theartmad.com/wp-content/uploads/2015/09/Best-Desktop-Background-1.jpg" alt="flat3" style="width: 100%;">
                        <div class="carousel-caption">
                            <h3>Bora</h3>
                                <p>During Day time</p>
                        </div>
                </div>
            </div>

            <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left"></span>
                <span class="sr-only">Previous</span>
            </a>    
            <a class="right carousel-control" href="#myCarousel" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right"></span>
                <span class="sr-only">Next</span>
            </a>
        </div><!-- Latest compiled and minified JavaScript -->
        
        <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://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>

Upvotes: 1

Related Questions