Why is the width attribute of a XUL button ignored? - firefox-addon

I have problems to set the width of my XUL button. I have this code:
<button label="Ok" width="16" maxwidth="16" height="16" maxheight="16"/>
By with that code, the size of my entire window is changed and not only the button.
And when I write that :
<button label="Ok" width="16" height="16"/>
Only the height is changed. Why is that?

XUL uses the flexible box model for positioning. The width and height attributes define the intrinsic size of the element, not the size at which they are displayed. Your button is apparently placed in a vertical box (not necessarily the actual vbox element, rather any element with orient="vertical"). By default, the align attribute of a box is assumed to have the value stretch - so a vertical box will always stretch the elements inside it horizontally:
<vbox>
<!-- this button is stretched horizontally to match the width of its container -->
<button label="Ok" width="16" height="16"/>
</vbox>
You can set the align attribute explicitly to avoid this:
<vbox align="center">
<!-- this button is centered inside its container -->
<button label="Ok" width="16" height="16"/>
</vbox>

Related

CSS3: Add vertical spacing between lines

I have some jQuery UI buttons that look like this:
How can I add vertical spacing between the rows? Modifying the CSS properties margin-top and padding-top didn't work.
Here is the HTML that exemplifies a single button:
<div>
<input type="checkbox" class="tool_toggle" id="tool_#" checked /><label for="tool_#">... tool name...</label>
... more inputs ...
</div>
This HTML input tag is simply repeated 11 times. The buttons wrap around as they should in the div container.
You can do it by setting line-height to the element that contains the buttons.
You need to specify that the buttons are display:inline-block before you can add margin-top or padding-top. This is because inline elements can not have top or bottom margins or padding.
You didnt post enough code to tell for certain so this is a guess. Post your CSS or make a http://jsfiddle.net/ if you want a proper answer

Prevent form element from spanning horizontally

By default form elements (input) in jQuery Mobile span over the full width of the screen.
How can I make them fit to the size of their content ?
You can use data-inline="true" on buttons and selects to make them span to the width of their content.

WPF : How to bind StackPanel height (which is auto) to ImageControl height?

I have stackPanel created in design (xmal) which has Auto height and width. Adding list of image controls dynamically in Code on Load to stackPanel. Now it works fine. But when i try to resize the window, though the stack panel gets resized due to auto, but not the image contrl.
How to bind the actualheight of stackpanel dynamically to image control height, (so when ever stakpanl height gets changed ,image control also should get changed !!).
thanks
Use a ViewBox
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Viewbox MaxWidth="500" MaxHeight="500" Name="vb1">
<Image Source="tulip_farm.jpg"/>
</Viewbox>
</StackPanel>
How to: Apply Stretch Properties to the Contents of a Viewbox
Or you could use binding as below:
<StackPanel x:Name="MyStackPanel">
<Image Source="C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg" Stretch="Uniform" Height="{Binding ElementName=MyStackPanel, Path=ActualHeight}"></Image>
</StackPanel>

How to set the image size same for portrait and landscape screen orientation in jquery mobile web application?

I have to add image on the header and background I added header image using following code
<div data-role="header" data-nobackbtn="false" data-theme="a" style="height:30px;background-image:url(test.jpg);background-repeat:no-repeat;">
the image perfectly fixed in the portrait but when the screen changed to the landscape, image not fixed perfectly there will be some blank space added after the image. So how to set the image same for both portrait and landscape screen orientation. This problem occur in Android,iphone ,blackberry ,etc. For more clarification please check the image header.
actually when set the width: auto or 100% is not working ,because the image has some fixed width for example I set image width as 360 px in portrait ,when change to the landscape the image width still same thats the problem. We can't set the width large for landscape because we can't say that all platforms landscape mode screen size is same. that may be varying in Android,iphone etc.
You can set a div tag to hide overflow, then set a regular img tag inside the div and set both to have a width of 100%...
<div data-role="header">
<a data-icon="arrow-l" data-rel="back" href="#" style="z-index:1001;">Back</a>
<div style="overflow:hidden; position:relative; width:100%; height:45px;">
<img src="test.jpg" style="width:100%; height:auto; position:relative;">
</div>
</div>
Some Notes:
the "height:auto;" sytle on the image can be removed if you are ok with distorting the aspect-ratio of the image when it scales.
the "z-index:1001;" style on the back button link is necessary because the header is given a z-index of 1000 (so the div around the image is also given a z-index of 1000 unless specified).

Change Silverlight transformation height direction

Here's my xaml
<Button x:Name="btnTest" Width="88" Content="{Binding Value, ElementName=slSlider}" Height="{Binding Value, ElementName=slSlider}" HorizontalAlignment="Left" ></Button>
<Slider x:Name="slSlider" SmallChange="1" LargeChange="10" Maximum="100" Height="32" VerticalAlignment="Top" UseLayoutRounding="False" d:LayoutRounding="Auto" HorizontalAlignment="Left" Width="256" ></Slider>
Very simple stuff. Now what I want to do is restrict the button to only grow in an upwards direction, instead of growing both upwards and downwards. How's this done?
Thanks
Set a MinWidth or MinHeight. There's also MaxWidth and MaxHeight if you need them.
Although re-reading your question I am unsure if you're asking about limiting the minimum size of the button or if you actually are talking about alignment. If you're talking about alignment and you want the top of the button to grow out while the bottom stays in position, set the VerticalAlignment of the Button to "Bottom".

Resources