Using React and Electron, resizing the browser window width below 980 pixels causes the page to be scaled down so that the content will always display 980 pixels wide and visible in the view port, no matter how tiny the viewport width gets.
In main.dev.js:
mainWindow = new BrowserWindow({
show: false,
width: 640,
height: 480
});
The browser window will open with 640px width, but the content will be scaled down so that 980px is visible. Where should this width setting be configured? I don't mind the feature for smaller viewports, but I'd prefer to use standard responsive styling to manage how the content will be displayed.
mainWindow = new BrowserWindow({
show: false,
width: 640,
height: 480,
minWidth: DesiredMinWidth,
minHeight: DesiredMinHeight,
});
This should work, if you want to configure a max height or width just replace min with max.
Related
I followed the tutorial on creating a popup for an add-on in Firefox, and it worked great.
The issue I'm having now is that the popup it creates doesn't change size to fit the content I add to it. Instead, it adds scroll bars.
So, how do I change the size of a Firefox Add-on SDK popup to show all content?
You do have to deal with that yourself.
If you already know the desired size when creating the panel, you can pass the height and width as properties of the object to the Panel() constructor.
After a panel is created, its size can be changed by setting the height and width properties on it.
height and width values are numbers in pixels.
See https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/panel for a full documentation of how to use panels.
Though the tutorial and docs never say it, the height and width of a panel always defaults to the same small size.
To change it you can use the height and width parameters for the panel class.
If you want it to change automatically you can use this code:
//index.js
var panel = require("sdk/panel").Panel({
height: 200, //choose your default
width: 200,
contentURL: data.url("popup.html"),
contentScriptFile: data.url("auto_resize_popup.js")
});
panel.port.on("resize", function (size) {
console.log(size);
panel.resize(size.width, size.height);
});
...
//auto_resize_popup.js
var content = document.body;
var size = {};
size.width = content.offsetWidth + 2; //2 extra pixels get rid of scroll bars
size.height = content.offsetHeight + 2;
self.port.emit("resize", size);
I want change size thumbnails. I want that width will be 200px and height will be proportional to the width.
In function I added
add_image_size( 'featured', 200, 9999); // create photo with width 200 and proportional height
But for vertical photo, its looks like:
<img class="wp-image" width="149" height="200" alt="1349431380_photobomb_02" src="http://wp-r/wp-content/uploads/2014/02/1349431380_photobomb_02-200x267.jpg">
how can set this width=200 and height=auto
I think I should use the function set_post_thumbnail_size but I can understand how can set height auto in this function.
Don't have to add code. Go to dashboard Settings/media set width and leave height box empty.
I have a small image in my project that I would like to resize responsively any time the resolution changes. I am currently using the class "img-responsive". With this class, the picture doesn't start resizing until the window reaches its edge. In this case, since it's a relatively small picture, this never happens.
Is there a built-in Bootstrap class I can use to have the image resize responsively at all times?
I ended up using JavaScript
$(window).resize(function(){
if($(window).width() < 1100){
var width = $(window).width();
var ceiling_width = 1100;
var difference = ceiling_width - width;
var decrease = difference * 0.2345;
var full_logo_width = 404;
var new_logo_width = full_logo_width - decrease;
$("#my_logo").css({"width": new_logo_width});
}
});
If the browser's width gets lower than 1100px then the picture will start shrinking. My image has a width of 404px by default (if the browser loads with a width of more than 1100px). I wanted the smallest possible width for the image to be a little over 200px. The per pixel decrease to per window width decrease variable (0.2345 in this case) was calculated based on this. I used the following CSS to set an upper and lower limit for the image's width.
#my_logo{
max-width: 404px;
min-width: 210px;
}
I'm trying to make a DIV width change as the browser size changes.
Not in some ratio that can be handled with percentage, but still with a dependency for the screen size.
I'm trying to make a div 80% max of the browser width, as long its divided by 20.
if screen is 1000px wide, so the div will be 800px, if the screen is 1024px so it will still be 800px (cause 80% of 1024 is 819.2, not divided by 20).
Except for doing a lot of media queries, I do not know how to do this.
This should hopefully get you on your way. It uses jQuery to resize the div by 20px increments. It's not perfect, but it's a start.
http://jsfiddle.net/ydtdS/3/
function tale(div,w) {
if(w%20==0) {
$(div).text(w);
$(div).css("width",w);
} else {
w = Math.floor(w / 20)*20;
$(div).text(w);
$(div).css("width",w);
}
}
$(window).resize(function() {
var windowWidth = $(window).width();
tale(".twenty",windowWidth);
});
tale(".twenty",$(window).width());
I am trying to achieve a layout like this:
where:
Navbar is just a bootstrap-like top menu, 60px of height, always on top
Pop-up menu is fixed in that position (not always visible), always on top
The entire free area (windows w.o. navbar) is filled with Canvas.
Live example: jsFiddle
I have a problem with Canvas. I currently have a simple style:
<canvas id="le_canvas">Y U NO CANVAS</canvas>
...
#le-canvas {
position:absolute;
width:100%;
height:100%;
}
and the canvas is filling the background, but:
the resolution is very low
it doesn't maintain ratio during window resizes.
What I'd like (if it is possible):
full resolution of the area to fill (1:1 pixel on canvas and on screen)
set the ratio of the area to fill
bonus: update the above after window resize
Setting the canvas element in per-centage will not set the actual canvas size which must be set in absolute pixels. What happens here is that you get a canvas with a default size which then is stretched by the html-rendering giving the blurry look.
You therefor need to set the size by using f.ex. the window's sizes in absolute pixels.
You can do this like this (update of fiddle here: http://jsfiddle.net/x5LpA/3/ ) -
Create a function that sets the canvas size based on window size (you will of course need to subtract height of bars etc, but to show the principle):
function initCanvasArea(cnv) {
cnv.width = window.innerWidth;
cnv.height = window.innerHeight;
}
As the canvas content are cleared when the canvas is re-sized you need to render the content again for each time. Therefor it will be smart to extract the render content into a separate function like f.ex:
function renderCanvas(ctx) {
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect(0, 0, 55, 50);
ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
ctx.fillRect(20, 20, 55, 50);
}
Now, make the main function a self-invoking one where you also attach an event handler for windo.resize to update the canvas:
$(function () {
var canvas = $('#le_canvas')[0];
var ctx = canvas.getContext('2d');
initCanvasArea(canvas);
renderCanvas(ctx);
window.onresize = function(e) {
initCanvasArea(canvas);
renderCanvas(ctx);
};
})();
And finally edit the CSS-rule by removing the width/height set to 100%;
#le_canvas {
position:absolute;
}
(Tip: a better approach here is to use the fixed attribute for position - plus use a wrapper element, padding, box-sizing.. but that is out of scope for this question).
Is this what you are after? I used $(document).width() and $(document).height() to get the width and height for the rectangle. http://jsfiddle.net/x5LpA/1/