1
I’m trying to fix a div containing two images (one below the other) but following examples and making some modifications the result was very different from expected, when I go scrolling on the page the div immediately goes to the left side of the page and returns to the right side when you arrive at the end of the page. Code:
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation"><!--------- START Navbar --------->
<div class="container">
<div class="navbar-header"><!-- START Brand and toggle get grouped for better mobile display -->
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Meu Site</a>
</div><!-- END Brand and toggle get grouped for better mobile display -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"><!-- START Collect the nav links, forms, and other content for toggling -->
<ul class="nav navbar-nav navbar-right">
<li><a href="#">News</a></li>
<li><button type="button" class="btn btn-info navbar-btn" data-toggle="modal" data-target="#login_modal">Login</button></li>
<li><button type="button" class="btn btn-info navbar-btn" data-toggle="modal" data-target="#create_account_modal">Create Account</button></li>
</ul>
<form class="navbar-form span7 text-center" role="search" id="search-form" action="../PHP/ValidateForm.php" method="get">
<div class="form-group">
<label class="radio-inline"><input type="radio" name="result_type" value="videos">Videos</label>
<label class="radio-inline"><input type="radio" name="result_type" value="photos" checked="">Photos</label>
<label class="radio-inline"><input type="radio" name="result_type" value="tumblr">Tumblr</label>
</div>
<div class="input-group">
<a href="#" class="btn btn-info input-group-btn" id="gly_button">
<span class="glyphicon glyphicon-th"></span>
</a>
<input class="form-control" type="text" name="search_input" placeholder="Search" />
<div class="input-group-btn">
<button class="btn btn-default" type="submit" name="search_form_submit" value="search">Search</button>
</div>
</div>
</form>
</div><!-- END Collect the nav links, forms, and other content for toggling -->
</div>
</nav><!--------- END Navbar --------->
<div class="wrapper" role="main"><!-- START Content -->
<div class="container"><!--- START Site Content --->
<div class="row">
<div id="conteudo" class="col-md-8"><!-- START News -->
<div class="row">
<div class="col-md-12 news_conteudo">
<div class="row">
<img class="news_thumb" src="../../app.images/7.jpg" />
<div class="news_information">
<button class="btn btn-xs btn-info" href="#" type="button">Publisher</button><br /><br />
<span class="title">Titulo</span><br />
<p class="texto">Resumos Resumos Resumos Resumos Resumos
Resumos Resumos Resumos Resumos Resumos Resumos Resumos Resumos Resumos Resumos Resumos
Resumos Resumos Resumos Resumos Resumos Resumos Resumos Resumos Resumos Resumos Resumos</p>
<span><span class="glyphicon glyphicon-eye-open pull-left" style="font-size:19px;"></span>
<span class="views pull-left">13.023 Views</span></span>
<span class="pull-right publish_date">Published in 12/December/2014</span>
</div>
</div>
</div>
</div>
<div class="row span7 text-center" id="video_pagination"><!-- START Pagination -->
<nav>
<ul class="pagination">
<li>
<a href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li>
<a href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div><!-- END Pagination -->
</div> <!-- END News -->
<div id="right-sidebar" class="col-md-4"><!-- START Left Sidebar -->
<div data-spy="affix" data-offset-top="70" data-offset-bottom="300">
<img src="../../app.images/4.jpg"/>
<img src="../../app.images/4.jpg"/>
</div>
</div><!-- END Left Sidebar -->
</div>
</div><!--- END Site Content --->
</div><!-- END Content -->
</body>
Image when page pasted at top:
Image with Scroll
Hello @Zuul I applied your answer to my code and got the following result: when I do the first scroll top to the ground works perfectly at the time it returns to the top the images disappear (return to the top instantly) and the scroll effect)
– Ricardo
@Ricardohenrique Or you have more CSS properties defined for the element
#right-sidebar
who subscribe to Bootstrap, or have broken HTML Markup that causes weird behaviors or have some Javascript breaking the behavior of the Affix plugin.– Zuul
I’ll be checking in and checking in
– Ricardo
There are no properties for the #right-sidebar element, and no javascript (other than datepicker,jquery,bootstrap.js)
– Ricardo
@Ricardohenrique There are then some problems in the HTML Markup... One thing is certain, for the HTML you have in question, the problem has been identified and the solution presented/proven. When I tested the images were walking from left to right on the page... after solving as I described in the question the problem was outdated....
– Zuul
I added the integral code, with the content of the contents of the contents, something else when the pull-right was excluded it had the function of making the images position itself to the right inside the two columns of the grid system since they do not occupy 100% of the grid
– Ricardo
@Ricardohenrique Another thing, if the HTML of the question is inside another HTML and this other HTML is broken or with attributes that will break the functioning of the Affix plugin, you have to analyze this to identify the problem. We do not have access to all your HTML and edit now the question to add another problem is an incorrect procedure, you must put a new question to deal with this new problem.
– Zuul
I added the whole body
– Ricardo
@Ricardohenrique However, I don’t know if you read my answer, but use CSS classes like
pull-right
and/orpull-left
in places where there may be a conflict of interest with the Framework and/or the Affix plugin will bring unexpected results. Use andpull-right
should be in the element to be floated or in a wrapper of the element never in the element that is part of the base structure of the page, namely thecol-X
.– Zuul
I removed the pull-right images
– Ricardo