I am struggling to implement turn.js
library on my responsive images. I thought that using JS libraries is easy but adapting the JS library to developer's code seems to be harder than expected.
I have written some code to show how I want the final result to look like - there is some #headings
div followed by #fbook
div which contains .fbookImg
images. In order to make the code less messy and more readable for You, I have decided to put only one image in it.
HTML:
<div id="headings">
</div>
<div id="fbook">
<img class="fbookImg" src="http://oi67.tinypic.com/30ue0bp.jpg" />
</div>
CSS:
#headings {
height: 100px;
width: 100%;
border: solid black 1px;
}
#fbook {
width: 100%;
border: dashed blue 1px;
}
.fbookImg {
height: 100%;
width: auto !important;
max-width: 100%;
position: relative;
display: block;
margin: 0 auto;
}
In the JS section I have some code to make images more responsive
JS (turn.js and jQuery are already linked):
$(document).ready(function() {
var a = window.innerHeight - 100;
$('#fbook').css('height',a);
});
$(window).resize(function(){
var b = window.innerHeight - 100;
$('#fbook').css('height',b);
});
FYI here is the fiddle/codepen: http://codepen.io/Janos/pen/wdwzVK
I tried to put more .fbookImg
images into #fbook
div ...
<div id="fbook">
<img class="fbookImg" src="http://oi67.tinypic.com/30ue0bp.jpg" />
<img class="fbookImg" src="http://oi66.tinypic.com/jkk13o.jpg" />
</div>
... and put there the appropriate turn.js
code according to the example on their official website ...
$("#fbook").turn({
display: "single",
autoCenter: true
});
... BUT the final result (fiddle here) is far away from what I wanted, it doesn't seem to respect my default styling at all and no effect is applied.