Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

JavaScript turn.js - unable to remove gap above and below image

jasonc310771

New Coder
I am using the https://github.com/blasten/turn.js/tree/master I used the demo magazine single page code.
This is what I currely have.
The turn effect works well, as required. But there is a gap above and below which I need removed, so the turn page effect is overlaid on the image corners. I put some borders around the elements to see if I could figure out where the issue was but still not finding this out after a few days now. Can anyone see what is causing the gap to show and what I can do, change, add to fix this ?
Image1.jpg
Code:
<!doctype html>
<html>
<head>
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.min.js"></script>
  <script type="text/javascript" src="scripts/turn.min.js"></script>

  <style type="text/css">
body {
  background: #ccc;
  margin: 0;
  padding: 0;
}

#magazine-container {
  border: 2px solid red;
  width: 300px;
  height: 600px;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  padding: 0;
}

#magazine {
  border: 2px solid green;
  width: 100%;
  height: 100%;
  font-size: 0;
  margin: 0;
  padding: 0;
}

#magazine .turn-page {
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: inline-block;
  vertical-align: top;
  position: absolute;
  top: 0;
  right: 0;
  width: 50px;
  height: 50px;
  z-index: 1;
  margin: 0;
  padding: 0;
}

#magazine .turn-page img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  margin: 0;
  padding: 0;
}


.turn-page {
border: 3px dashed red;
  margin: 0 !important;
  padding: 0 !important;
}


img {
border: 3px dashed blue;
  display: block;
  margin: 0;
  padding: 0;
}

  </style>
</head>
<body>

 
<div id="magazine-container">
 <div id="magazine">
  <div class="turn-page" style="background-image:url(pages/01.jpg)"><img src="pages/01.jpg" alt="Page 1"></div>
  <div class="turn-page" style="background-image:url(pages/02.jpg)"><img src="pages/02.jpg" alt="Page 2"></div>
  <div class="turn-page" style="background-image:url(pages/03.jpg)"><img src="pages/03.jpg" alt="Page 3"></div>
  <div class="turn-page" style="background-image:url(pages/04.jpg)"><img src="pages/04.jpg" alt="Page 4"></div>
  <div class="turn-page" style="background-image:url(pages/05.jpg)"><img src="pages/05.jpg" alt="Page 5"></div>
  <div class="turn-page" style="background-image:url(pages/06.jpg)"><img src="pages/06.jpg" alt="Page 6"></div>
 </div>
</div>

  <script type="text/javascript">
    $(window).ready(function() {
      // Initialize the magazine
      $('#magazine').turn({
        display: 'single',
        acceleration: true,
        gradients: !$.isTouch,
        elevation: 50,
        when: {
          turned: function(e, page) {
            /*console.log('Current view: ', $(this).turn('view'));*/
          }
        }
      });

      // Set the initial height of the magazine
      resizeMagazine();

      // Add a window resize event listener
      $(window).resize(function() {
        resizeMagazine();
      });
    });

    function resizeMagazine() {
      // Get the current window height
      var containerHeight = $('#magazine-container').height();

      // Set the height of the magazine container
      $('#magazine').height(containerHeight);

      // Set the height of the turn-page elements
      $('#magazine .turn-page').height(containerHeight);

      // Refresh the magazine to update the layout
      $('#magazine').turn('size', '100%', containerHeight);
    }

    $(window).bind('keydown', function(e) {
      if (e.keyCode == 37)
        $('#magazine').turn('previous');
      else if (e.keyCode == 39)
        $('#magazine').turn('next');
    });
  </script>

</body>
</html>
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom