Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1240
  • Last Modified:

how to display scrollbar for extra data while using span tag or div tag

hi,
my manager wants to use span or div tag with scroll bar to hav extra navigation
my question is : is this donable if the answer is yes would you please give me a how to example

best regards
hatem gamal
<html>
  <head>
    <title>Using a span</title>
 
    <script language="javascript">
      function displayText()
      {
       document.getElementById('targetSpan').innerHTML =
          "You're using JavaScript";
      }
    </script>
 
  </head>
 
  <body onload="displayText()">
 
    <h1>Using a span</h1>
 
   The new text will appear here: "<span id="targetSpan" style="width:10px;">
    </span>".
 
    </body>
</html>

Open in new window

0
hatem_from_mesr
Asked:
hatem_from_mesr
1 Solution
 
alexpercsiCommented:
You can't really display scrollbars on span tags unless you set display:block on them, which essentially turns them into DIV tags (they behave like DIVs)

To make a scrollbar visible when entering extra text you need to set a few CSS styles on the enclosing DIV.
1. Fixed width or height (or both, depending on whether you want a vertical or horizontal scrollbar - or both)
2. overflow:auto; (this means that the scrollbar will only appear if the content is larger than the specified fixed height or width)

For your span tag I would recommend changing it into the code snippet below. Please note that I have increased the width because 10px is too small to even display the scrollbar. The code below will create a 100px wide by 100px tall DIV tag that will display scrollbars as necessary:
<div id="targetSpan" style="width:100px;height:100px;overflow:auto;">
    </div>

Open in new window

0
 
hatem_from_mesrAuthor Commented:
thanks man
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now