Solved

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

Posted on 2009-05-17
2
1,228 Views
Last Modified: 2013-11-19
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
Comment
Question by:hatem_from_mesr
2 Comments
 
LVL 7

Accepted Solution

by:
alexpercsi earned 500 total points
ID: 24405929
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
 

Author Closing Comment

by:hatem_from_mesr
ID: 31582343
thanks man
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
window.setInterval not firing 7 29
Angular - break the dataset in chunks? 7 39
how would you interpret lines 3 29
is this a cms? 8 33
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now