By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,570 Members | 1,712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,570 IT Pros & Developers. It's quick & easy.

How to make an image horizontally scrollable but vertically fixed??

Ashwani Sharma
P: 46
There is a page with both horizontal and vertical scrolling and there is an image too which have its fix position but what I need is it should get fixed with its position when scrolling page vertically but it should move with the page when scrolling horizontally.

Please give your precious suggestions to help me out with this problem.

Thanks in advance,
Ashwani Sharma
Mar 4 '11 #1
Share this Question
Share on Google+
3 Replies


drhowarddrfine
Expert 5K+
P: 7,435
It does work that way with 'position:fixed' so there is something else in your markup causing this but without the complete listing or a link, it's just a wild guess.
Mar 4 '11 #2

Ashwani Sharma
P: 46
Here is the markup:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body style="width:2000px; height:1200px;">
<div style="width:200px; height:200px; display:block; border:solid 1px #000000; background:#cacaca; position:fixed;"></div>
</body>
</html>

Now I need this div to move with scrolling horizontally but not vertically ..
Mar 4 '11 #3

drhowarddrfine
Expert 5K+
P: 7,435
Now that I'm awake, I realize I misunderstood the horizontal part. Fixed positioning is just absolute positioning so you could tinker with things there. Otherwise, a javascript solution can do this.
Mar 4 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.