I have a vetical flex box container with two flex boxes. Te bottom one is fixed size and the top one takes up the rest of the space. This works great.
<div id="outer">
<div id="A">
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>
Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>
</div>
<div id="B"></div>
</div>
CSS:
body, html{
width: 100%;
height: 100%;
}
#outer{
width: 100%;
height: 100%;
background: yellow;
display: flex;
flex-direction: columN
}
#A{
height: 20px;
max-height: 100%;
width: 100%;
flex: 2;
background: #cccccc;
overflow: auto;
}
#B{
height: 200px;
width: 100%;
background: blue;
}
JS:
$("#B").resizable({
handles: "n"
});
I i now make the bottom one resizable with jquery ui i get a strange behaviour. For some reason jquery ui not only sets the size (height) of the bottom container but also the "top" property.
Is there anything i can do to keep resiable from setting this top property?
http://jsfiddle.net/t6B2e/8/
Your jQuery set your element in absolute position.
you can test and find out using !important to override some of the CSS set by jQuery: http://jsfiddle.net/t6B2e/9/
#B{
height: 200px;
width: 100%;
background: blue;
/* overrides any inline style or javascript style */
position:relative!important;
bottom:0!important;
top:auto!important;
}
Related
<v-stage :config="{width:750,height:750}">
<v-layer>
</v-layer>
</v-stage>
will render
<div>
<div
class="konvajs-content"
role="presentation"
style="position: relative; user-select: none; width: 750px; height: 750px;"
>
<canvas
width="750"
height="750"
style="padding: 0px; margin: 0px; border: 0px; background: transparent; position: absolute; top: 0px; left: 0px; width: 750px; height: 750px; display: block;"
></canvas>
</div>
</div>
but I want to make it render
<div>
<div
class="konvajs-content"
role="presentation"
style="position: relative; user-select: none; width: 100vw; height: 100vw;"
>
<canvas
width="750"
height="750"
style="padding: 0px; margin: 0px; border: 0px; background: transparent; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; display: block;"
></canvas>
</div>
</div>
keeping the canvas.width(attribute) stay in 750, but change div.konvajs-content.style.width to 100vw, and canvas.style.width to 100%
=== update ===
Why I need this ?
I'm creating an image editor, and the users may save the image exported from the cavnas, I want the canvas be responsive in layout, but I also have to make the image exported from the canvas have the same width, 750 in my case.
This is something like what a html5 game engine with scale manager would do.
Konva doesn't work well in the case when you change the CSS styles (like width and height) of a stage or canvases.
If you want to make it responsive behavior you can do it differently. Just place a stage into the div container with required size (configured with styles). Then set the stage size to the size of the container.
// your desired "virtual" width of the stage
var stageWidth = 750;
var container = document.querySelector('#stage-parent');
// now we need to fit stage into the container
var containerWidth = container.offsetWidth;
// also we can scale the stage
var scale = containerWidth / stageWidth;
stage.width(containerWidth);
stage.scale({ x: scale, y: scale });
stage.draw();
Take a look into this demo: https://konvajs.org/docs/sandbox/Responsive_Canvas.html
How to change chart's width to fill up div when hide/open left side nav menu using angular2-highcharts??
I tried to use style="display:block; width: 100% !important;" as recommended on most resources I found, but it didn't help.
Here is an example of using chart inside mat-sidenav-container and mat-sidenav-content:
Html
`<mat-sidenav-container class="sidenavContainer">
<mat-sidenav #sideNav opened="true" mode="side" class="filters-viewer-sidenav">
mat-sidenav
</mat-sidenav>
<mat-sidenav-content>
mat-sidenav-content
<button (click)="sideNav.toggle()">
mat-sidenav-button
</button>
<div style="width: 100%; height: 100%">
<chart [options]="options" style="display:block; width: 100% !important;"></chart>
</div>
</mat-sidenav-content>
</mat-sidenav-container>`
css
`html, body, mat-sidenav-container, .chart-wrapper {
margin: 0;
width: 100%;
height: 100%;
}
.sidenav {
width: 240px;
height: 100%;
box-shadow: 3px 0 6px rgba(0,0,0,.24);
}`
Added also screenshot: after I close left side nav menu, chart width stays the same.
still_same_chart_width_size
One of the solution was to delay rendering of the chart. I used ngAfterViewInit() lifecycle hook:
ngAfterViewInit() {
setTimeout(() => {
if(this.chart) {
this.chart.reflow();
}
},100);
}
This can be done with css
chart {
width: 100% !important;
margin: 0 auto;
display: block;
}
Check https://github.com/gevgeny/angular2-highcharts/issues/11
I made a webpage with a sticky header that works fine on a desktop but not so well on mobile. For example, on an iPhone, if you turn your phone on to landscape mode, safari's tool bar will cover my sticky header. Similarly opening a link to my page on instagram will result in the same issue (instagram header will cover mine).
Heres's the HTML
<div id="container">
<div id="infotab-mobile">
<div id=rosemenu>
<div id="rose">
<img class="inforose" id= "roseimg" src="images/rose.png">
</div>
</div>
</div>
and the CSS:
#infotab-mobile{
display: initial;
justify-content: space-around;
flex-wrap: wrap;
width: 100%;
position: fixed;
z-index: 999;
}
#rosemenu{
position: fixed;
width: 100%;
height: 20%;
display: inline-block;
}
#rose{
position: relative;
width: 100%;
vertical-align: top;
text-align: center;
background: rgba(232, 232, 232, 0.96);
padding-top: 2%;
padding-bottom: 2%;
}
#roseimg{
margin: 0 auto;
text-align: center;
display: -webkit-box;
}
I've also noticed that using -webkit-overflow-scrolling: touch; disables an ios feature that allows you to scroll to the top of a web page by taping the safari tool bar. Has anyone discovered any work arounds?
I have one div containing an image and a translucent window over it that is draggable and resizable. I am using the parent div as the containment parameter for the respective jQuery UI interactions. But when I resize the window, I can only resize it to 10px less than the parent width. No matter which image I use. No issues resizing to the full height. No issues dragging to the far right or bottom.
Here is the code (Try it here - JS Fiddle)
HTML:
<div id="container">
<div id="navi">
<img src="http://www.mountainevolution.com/Cento%20Fonti/images/dscn7587.jpg" />
</div>
<div id="infoi">
</div>
</div>
CSS:
#container {
width: 100px;
height: 100px;
position: relative;
}
#infoi {
position: absolute;
top: 0px;
left: 0px;
background-color: lightblue;
border: solid 1px navy;
width: 100px;
height: 100px;
opacity: 0.5;
}
#navi {
padding: 0px;
position: absolute;
}
#navi img {
display: block;
}
JS:
$("#infoi").draggable({
containment: "#navi"
});
$("#infoi").resizable({
containment: "#navi"
});
I have played around with margins and padding, and also looked at other questions on StackOverflow. None of them are similar to mine. There are some questions on problems with using resizable and draggable together. In my case, removing draggable does not affect the issue, so I don't think it is a problem with using them together.
I have been working on building my first CSS site using divs and am having an issue with a button. While I am able to get the button to work on rollover, the link does not respond. Can somebody please advise. Thank you.
HTML:
<div class="wrapArrow">
<div class="arrow" style="cursor: pointer;"><span>home</span></div>
</div><!-- END wrapArrow -->
CSS:
.wrapArrow {
margin: 70px 0 0 0;
padding: 0;
width: 20px;
height: 20px;
float: right;
}
.arrow {
display: block;
width: 20px;
height: 20px;
background-image: url(../images/nav/arrows.gif);
background-repeat: no-repeat;
}
.arrow:hover {
background-position: 0 -20px; }
.arrow span {
display: none; }
Since your <span> is not displayed, your link has no content, so it gets collapsed to a width and height of 0, thus making it unclickable.
Why not just make the anchor itself have the arrow class?
<div class="wrapArrow">
<span>home</span>
</div><!-- END wrapArrow -->
.arrow a is 0 x 0 px
Makes it really hard to click. Believe me I tried.
Try:
.arrow a {
width: 100%;
height: 100%;
display: block;
}
It looks like you need to get rid of
.arrow span {
display: none;
}
Is there any reason that needs to be there? With display set to none you are hiding the clickable element that is necessary for the link to work.