I am doing image cropping in my webpage.My problem is that when i crop a large image which is larger than the container holding the image,scroll bar is not automatically coming.So i am unable to crop the large image whose remaining part is under the container which is not visible to the user.So is there any way to create automatic scroll bar.thanks in advance.
You want to use the css overflow property
<div style='overflow:auto;width:300px;height:300px;'>
<img src='image.png' width='1000' height='1000' />
</div>
Which will load an image 1000x1000 pixels, but a scrollable area of just 300 x 300 pixels.
Other possible values of overflow are: visible, hidden, scroll, auto, inherit
http://www.w3schools.com/cssref/pr_pos_overflow.asp
Related
I have a background-image in a block as seen in the page link below.
I am trying to display the image as follows:
I want the image to consume more of the page background (irrespective of how much content is in the div block
I need the image to extend outside the boundaries of the block it is in
I want to the image to be responsive
It seems that my image grows and shrinks as I add more content or take content away. Is there anyway to get the image to appear larger than it is (ideally ~90% of viewport width) and retain its 90% size across various screen resolutions?
http://bit.ly/1IgmNKT
Thank you.
Try:
background-size: 100% auto;
i have several svg's included in and image tag on my homepage.
My svg's are resized to the parent div container, which is 30em's wide.
My problem now is that i have svg's are not of the same width and all of them are scaled to a width of 30em.
See this example:
jsfiddle.net/xpgz44oL/
The displayed font-size should be the same for every svg.
How can i achieve this?
Assuming the original drawings were done at the same scale, you could look at the viewBox widths and set each image to that width (or a multiple of that width if you want them bigger).
<div>
<img src="http://www.austrokamin.at/media/dw/zeichnungen/laengenelement-1000mm-dw-zeichnung.svg" width="158.95px"/>
<img src="http://www.austrokamin.at/media/dw/zeichnungen/dachdurchfuehrung-20-35-grad-dw-zeichnung.svg" width="239.19"/>
</div>
The situation is a jqGrid inside a div where the size of the grid is larger than the div both vertically and horizontally. The goal is to have the column headers scroll left and right with horizontal scroll, and also keep them always visible when scrolling vertically.
It is easy enough to add CSS to have both scrollbars by setting overflow-x: auto to the div containing the jqGrid and overflow-y to auto for the ui-jqgrid-bdiv.
The problem with this technique is that the vertical scrollbar is only visible when the grid is scrolled horizontally to the right enough to show the right side of the grid. Making the ui-jqgrid-bdiv scroll and using DOM manipulation to set the sizes of the containing elements results in both scrollbars being visible, but the body content scrolls without scrolling the column headers.
There is a similar stack overflow question JqGrid add vertical scroll with horizontal scolling, but the answers do not address this.
It doesn't look as if there would be a pure CSS solution given the DOM structure of the grid. Is there a JavaScript solution out there, perhaps one listening to scroll events?
You could set the height and width property of the grid itself so that the grid will take care of the scrolling instead of the div that it is nested in. Set the dimensions to be the same or slightly smaller than the div's.
<div style="height:200px; width:100px;">
<table id="grid"></table>
</div>
<script>
$("#grid").jqGrid({
height: '200',
width: '100',
shrinkToFit: false //Tells the grid to let columns go to set size
//Add all your properties
});
</script>
OR
if you can get away with not setting the width and height of the parent div, you can just set the grid's dimensions like shown above. As long as the grid's properties are set to a certain size, it will make it's own scroll bars if the data is outside of those bounds.
jsFiddle
there is probably a very simple answer to this very simple question, but i just can't to seem to find it, and its driving me crazy. what I have is a div element at the bottom right corner of the window with an image in it approx. 260 x 300 px.
my css code is this:
#doomdiamond{
position:absolute;
right:50px;
bottom:50px;
}
and html is this
<div id="doomdiamond">
<img src="doomdiamond.gif" />
</div>
all pretty simple. the element shows up with the image inside of it at the proper distance from the browser window. but what i really want it to do is scale/resize itself proportionally when the browser is resized, instead of staying the same size.
this is possible right?
I have created an example for you showing an image that sits in the lower-right corner, with the size based on the width of the window.
It works by setting the image width to a percent value. Percentages are based on the containing parent; because I did not cause the #doomdiamond div to be absolutely placed, it is not the positioned parent of the object.
Setting only the width or height of an img element causes the image to be proportionately scaled.
P.S. This uses no JavaScript :p
Yes it is possible, you will need some JavaScript to do it though. Are you using any JS frameworks ?
UPDATE
Looks like resize div and its content on browser window resize is what you're looking for
I have...
<div id="tabs">
<!-- ... -->
<div id="interior-photo">
<img src="...">
</div>
<!-- ... -->
</div>
... and ...
#interior-photo { overflow-x: auto; }
Basically, I have a page broken down into a main section and a fixed-width right sidebar. Within the main section, I have my tabbed div. The entire page grows with the width of the window, so when the window is resized, the tabbed div grows horizontally in size too.
My problem is that the image that I'm loading inside one of the tabbed divs is generally much, much wider than the window usually is (they're panorama pictures; very lengthy horizontally, but not much vertically).
I know that I can force the contents of #interior-photo to scroll horizontally using the CSS rule above, but that only seems to work when that same div has a fixed width. Since I want that div to have a variable width, it always seems to display the full width of the image, pushing my layout way out of whack.
I know how to fix this using Javascript, but I was wondering if anyone has a CSS-only solution. If you need more information about my layout to solve this issue, please let me know. Thanks!
Unless your target div is constrained either by a fixed width style or by a container with a fixed width or whose ancestors include a fixed width, you won't be able to get your target div to acquire scrollbars. It will just go as wide as its contents, and the browser scrollbars will take over.
Actually, there is a way around this. You can specify to display the image with scrollbars, and thus confine the viewable portion to the size of the div. Basically, the image will expand to the size of the div, and then have a horizontal scrollbar if the horizontal image size exceeds the horizontal size of the div. Scrollbars will not be displayed if the image's vertical component exceeds the div's. You can set both the x and y to scroll on overflow with the overflow declaration. However, in order to use any of these, the div's size must be controlled through some means, even through the initial declaration.
#interior-photo { overflow-x: scroll; }