height

Set the height of a div to be half of whatever the width is

社会主义新天地 提交于 2019-12-03 02:01:49
How can I set the height of a div to be exactly half whatever the width is, when the width will change depending on the users screen size? I have the following set on a div... #div1 { min-width:400px; width:100%; max-width:1200px; height:400px; background-color:red; } The width works fine on this, it locks at 400 pixels if the screen gets too narrow and it also stops expanding at 1200 pixels if the screen gets too big. But, I also want the height to change to be exactly half of what the width is at any given time. Something like... #div1 { min-width:400px; width:100%; max-width:1200px; height

Change height on div with javascript

拟墨画扇 提交于 2019-12-03 01:19:28
问题 I want to set the height on a div when the div is more than 100px in height. For example, when the content of the div makes the div's height fill more than 100px, I want it automatically fit to 200 px. 回答1: One way you can do this is to make sure there is no "height" attribute in the elements CSS (inline styling is fine). Then, when the content is changed call this function: if ($('#myDiv').height() > 100) { // Div is larger than 100px so increase it to 200px $('#myDiv').css('height', '200px'

jQuery sortable item height

落花浮王杯 提交于 2019-12-03 01:15:29
I've got a simple jQuery sortable based on a list as follows: <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> I've created a helper function so that regardless of what the contents of an item may be, the helper is always the same fixed size. My problem is that if I drag an item that has a lot of content (says several paragraphs of text), even though my helper is only a single line in height, the item will not drop onto the item below until it has travelled at least the original height of my item. For example: <ul> <li>Item 1 line2 line3 line4 line5 </li> <li>Item 2<

How to properly set the 100% DIV height to match document/window height?

人盡茶涼 提交于 2019-12-03 01:13:52
问题 I have a wrapper positioned to center with an y-repeated background image: <body> <div id="wrapper"> ...some content </div> </body> #wrapper{ width: 900px; margin: 0 auto 0 auto; background-image: url(image.jpg) 250px 0px repeat-y; } Problem: when the window size is higher than the wrapper's height inherited from its content, the image obviously doesn't repeat on y-axis all the way to the bottom of the window. I've used jQuery to dynamically apply inline CSS style to the wrapper according to

Printing a bootstrap page from Google Chrome cause (sometimes) truncation height of the printed page

為{幸葍}努か 提交于 2019-12-03 00:21:45
Starting from this official template: http://getbootstrap.com/examples/jumbotron/ of bootsrap v. 3.3.7 and using Google Chrome v. 54.0.2840.99 m (64-bit), on maximized window 1920px monitor, when i try to print the page in A4 horizontal format the print preview (and the saved PDF or printed page) is height truncated. In this specific case should be 2 pages height instead of 1. This happened when: Printing from Chrome (in Firefox v50.0.1 and IE11 the issue is not present) When the cols are not collapsed while i'm printing in screen mode (in the above boostrap example when the width of the

JavaScript - function to get real image width & height (cross browser)

喜欢而已 提交于 2019-12-02 23:39:22
问题 How to get real image width & height (cross browser) by JavaScript function ? 回答1: First of all, you have a greater chance of getting your question answered if you'd just ask it in a more polite way, and supplying as much relevant information as possible. Anyway... For as far as I know, you can use the .width property across pretty much all browsers: function getDimensions(id) { var element = document.getElementById(id); if (element && element.tagName.toLowerCase() == 'img') { return { width:

Two DIVs inside DIV. How to auto-fill the space of parent DIV by second DIV?

北城以北 提交于 2019-12-02 23:38:38
Please visit this fiddle to see what I mean - I have a parent DIV, within that there are two DIVs placed in vertical order. The top DIV should have only the height of its content, whereas the bottom DIV should occupy all remain space of the parent DIV irrespective to content heights, and also shouldn't overlap the parent DIV. HTML: <div class="outer"> <div class="inner-title"> THIS IS MY TITLE </div> <div class="inner-content"> CONTENT AREA </div> </div> CSS: html,body { height: 100%; } .outer { background-color:blue; height: 80%; } .inner-title { background-color:red; } .inner-content {

Win32 C++ - Check if the Window PositionX/PositionY and Width/Height changed

别说谁变了你拦得住时间么 提交于 2019-12-02 23:16:57
问题 It is possible to check whenever the X/Y position of the window changed? Also, if it's possible to check if the Window Width/Height changed too. 回答1: You're looking for the WM_MOVE and WM_SIZE messages. 回答2: As already answered, you can handle WM_SIZE and WM_MOVE. But you can also intercept the messages before they have any effect by checking WM_WINDOWPOSCHANGING (except in the case where a call to SetWindowPos passes SWP_NOSENDCHANGING - but that is usually deliberate and completely under

C# show scrollbars if shape height is greater than form height

廉价感情. 提交于 2019-12-02 22:07:52
问题 I just need to show scrollbars on forms if my shape height is greater than the form height. That way, when the user scrolls down, it can show the end of the shape. This is my code: public partial class Form1: Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawLine(new Pen(Color.Black, 2), 100, 50, 100, 1000); //if line height > form height then show scroll bars } }

Internet Explorer doesn't honor my min-height: 100% with flexbox

廉价感情. 提交于 2019-12-02 21:44:25
I've been looking through all the min-height: 100% solutions on StackOverflow and the web and I can't seem to find one that fits my (relatively simple) needs. Here's what I want: I have a two column container, and both columns should stretch to be equal height. When the content doesn't fill the screen, the columns should stretch to the full window height. I'm happy to use flex-box, but I'd prefer not to use JS hacks if possible. Example Code: http://codepen.io/anon/pen/dwgDq?editors=110 <!DOCTYPE html> <html> <body> <div class="container"> <div class="nav"> <p>Item 1</p> <p>Item 2</p> <p>Item