Strange iframe height behaviour when placed in a table cell - css

I'm having a problem with iframe height when placed within a table cell. Firefox and Chrome set its minimum height at 150px while Internet Explorer handles lower height. When cell's height is more than 150px, iframe follows nicely.
The interesting thing is that when placed within a div its height is correct regardless of div's height being less than 150px but within a table cell height seems to follow its own rules (set by the browser).
Here's a JSFiddle
Example iframe test are as followed:
iframe in a div with height of less than 150px
iframe in a table cell with height less than 150px
iframe in a div with height more than 150px
iframe in a table cell with height of more than 150px
Additional limitation
Since it seems that iframe works fine when placed within a div that could be a nice solution, but I can't control HTML since it's part of third party controls that render iframe within a table cell. Javascript manipulation is of course always an option, but I would like to resolve this by using CSS only. And since container's height is controlled by the third party as well, I can't change iframe's height to fixed height.

This 150px limit for an iframe in a table cell has been reported as a bug in the Gecko/Webkit browser engine:
https://bugzilla.mozilla.org/show_bug.cgi?id=253363
https://bugzilla.mozilla.org/show_bug.cgi?id=324388
It has also been remarked upon by the Telerik RAD controls dev team (see here). I haven't found a definitive reason as to why it was decided that 150px is a mandatory minimum, but it does explain the behaviour you were seeing.

You could try to set the table and its children to display: block.
http://jsfiddle.net/willemvb/aM2Fx/
table,
tbody,
tr,
td{
position: relative;
display: block;
width: 100%;
height: 100%;
}
Or you could use relative positioning on the table, and absolute on the iframe.
http://jsfiddle.net/eeZHZ/
table
{
width: 100%;
height: 100%;
position: relative;
}
table iframe {
position: absolute;
top: 0;
}

Related

Sticky header with scrollable content height does not fit inside card body

I am trying to make my table header fixed with rest of the table body scrollable in my react application.
This I have been able to achieve using the following css
// Parent Container
.Table-Container {
max-height: 60vh; //Making my table height unresponsive for some reason
min-height: 40vh;
max-width: 100vw;
position: relative;
overflow-y: scroll;
margin: 1rem;
}
// Styling and posiition for table header
.tableHeader .th {
position: sticky;
top: 0;
}
My layout is something like this.
Card is expanding because of the values assigned to table height to make it scrollable and header sticky
I don't want my wrapper content to scroll. The card height should not expand outside the remaining space
Ideally, I want header and footer fixed and the remaining space should be utilised by the breadcrumb, Filter buttons for the table(if any) and my table itself (again with fixed header) with the ability to auto expand/shrink based on the available space
I want the table height to fit inside the cardbody(parent div) automatically, but without assigning height, the scroll wouldn't work. It is only considering height in px or vh. Setting the height to auto also wouldn't work.
I want this to be responsive across different screen sizes.
Declaring a height in vh is also coming in the way of making it responsive.
Would appreciate any help or direction on this.
Thanks
I tried to set the height to my main-content like this
.main-content {
height: calc(100vh - #{$header-height} - #{$footer-height})
padding: calc(#{$header-height} + #{$grid-gutter-width})
calc(#{$grid-gutter-width} / 2) $footer-height
calc(#{$grid-gutter-width} / 2);
}
The card is still expanding outside the defined height of the parent.
I even tried using box-sizing: border-box but this wouldn't have any impacts either.
When I use this logic in a normal html + css this works perfectly,
However in react it is not behaving as expected.

How to use an image placeholder while images load in a responsive grid?

Using a responsive fluid grid and images are 800px x 500px
Problem: When images load, the footer as it the top and is pushed down while the images are loading in.
Setup: Using a div for the images and div for the footer.
Goal: To have the footer always remain in the correct position, not trying to put it in an absolute spot, just looking to have the images spacing accounted for.
Ideas: Perhaps use a transparent png at 800x500 so it loads first before the images.
Concerns: Creating a div placeholder at 800x500 might not work as these images are responsive in a fluid grid so they'll never actually be at that size unless the viewer has a huge monitor..
Final result when images loaded:
Current issue:
Goal for images to load:
When I know the aspect ratio for something is going to stay the same no matter what the width of the elements/screen is, I do something like this:
.image-holder {
display: inline-block;
width: 33.333%;
position: relative;
}
.image-holder:before {
content:"";
display: block;
padding-top: 62.5%;
}
.image-holder img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Here's a full demo: http://jsfiddle.net/serv0m8o/1/
I wrap each image in a div with a class of image-holder (which is styled to give you the 3 per row pattern that you illustrated) and make sure it is position: relative;
I then style the :before pseudo-element of that div to be the proper height of the aspect ratio that is needed. Padding in CSS is an intrinsic property, which means it is based on the width of the element, allowing you to assign a percentage which reflects the ratio. You specified 800x500 images, so (500/800*100) = 62.5% as my padding-top
Then, you can absolutely position your image to fill the full width and height of the container (which is why we set it to be position: relative;)
Doing this means that the div element is the size that the image will be, whether the image is loaded into it or not (the image itself has no bearing on the container size, since it is absolutely positioned)

Setting max-height relative to browser window size, not body size

I have a modal popup box on my site, inside the <body> tag.
This is the styling of the popup:
.modalbox {
text-shadow: none;
position: absolute;
padding: 22px;
left: 50%;
background: white;
z-index: 90;
border-radius: 6px;
display: none;
font-size: 14px;
width: 80%;
}
Setting the width is simple. However, the vertical content is dynamic and therein my problem lies - I don't want the box to be taller than the browser window.
I've tried setting max-width: 90%;, and this works if the body of the page is not longer vertically than the browser window.
However, when the body overflows (and scrollbars appear), then the 90% maximum height above is relative to the height of the body, not the window. This means that the modal box can overrun out of the window vertically, forcing the user to scroll the page to see its full content.
What I want to accomplish is for that max height to be 90% of the browser window so that the entire modal box is visible at all times.
I will handle overflow, I just need help figuring out how to restrict the vertical size in the way described above.
Use the viewport-percentage lengths.
The viewport-percentage lengths are relative to the size of the initial containing block. When the height or width of the initial containing block is changed, they are scaled accordingly.
.modalbox {
max-height: 90vh; }
There isn't a way to do this with html or css as far as I know, you'd have to accomplish this using JQuery:
http://api.jquery.com/height/
// Returns height of browser viewport
$( window ).height();
and then just use whatever 90% of the height value is.

How may i set the height of div to fill the browser height?

Please visit my website at http://amrapps.ir/personal/indexbug.html
to visually see my problem.
Let me explain my problem:
In my website i have a fixed postion div which contains links and i takes and it takes 25 % of browser height.
Then it is the red div which takes 75 % of browser width.
When user clicks on -CLICK THERE TO READ MORE- in red div,it will be redirected to the next(yellow colored) div which takes 100 % of browser height.
Then you can click on go to top on the fixed div above to get back to red div.
Navigations are working well but there's a problem.
When you are at the 2nd(yellow) div,if you change browser width,the red div will be also visible! How can i fix that?
thank you for your effort.
Change your #aboutmore class to the below css:
#aboutmore {
background-color: #FFCE85;
margin-top: 5px;
top: 25%;
position: absolute;
/* height: 74%; */
width: 100%;
min-width: 1130px;
bottom: 0px;
z-index: 3;
}
Theres a couple of things going on here, and I'm not 100% of the result you want to accomplish, but we are working with CSS heights here so you need to keep some things in mind.
First of: when working with css heights, you need to make sure that all wrapping elements get the height of 100%. Including your body AND html tags. Without this, your body will just have the height of the elements inside it, and your 100% divs will do it to.
Second, you should turn of the body 'overflow: hidden' attribute, as it just obstructs correct testing.
Now, like I said, I'm not sure what you're trying to accomplish, but your header should be taken out of the wrapper as it is fixed. This will allow your wrapper to become the scrollable area. You also mentioned you wanted the second div to be 100% heigh and the first one 75%. Now, with position fixed this would mean your yellow div is only 75% visible, with 25% hidden (either by being off screen or under the header). If you want the first div and header together to take up 100%, and any subsequent div to take up 100% on their own, you should position all elements relative and not fixed.
I'm going to add some code here to help with a fixed header:
div#page-wrap {
height: 75%;
position: absolute;
top: 25%;
width: 100%;
overflow: scroll;
overflow-x: hidden;
}
about,
#aboutmore {
height: 100%;
position: relative;
top: 0%;
}
Now this will break your javascript (as you can't actually scroll the body), although I couldn't get it working in the first place anyhow. You'll find more about scrolling inside a div (as now you need to scroll in your wrapper element) in this thread: How do I scroll to an element within an overflowed Div?

Inject a panel on websites

I would like to inject an iframe on the right side on a website to create a vertical panel. As "panel" I mean : it should be on the right side, cover the full visible height of the page, not be affected by scrolling, but "push" the website content (as opposed to cover).
I tried modifying padding-right on , but it doesn't work on all websites (and only affect non-positionned elements).
It should work on any website with weird layout, e.g. http://orange.jobs/
Injection is not a problem (it's a Chrome extension).
You can do this via css. To cover the full visible height and make the position of this element fixed on the site do:
position: fixed;
top: 0;
right: 0;
bottom: 0;
width: 100px;
Try not to use
height: 100%;
as this would be rendered differently by every browser. Use top and bottom instead. You can choose a width with percentage or pixel values.
This css code could be applied to every html element.
If there are issues with positioning try to add
display: block;
or
display: inline-block;
I've added a jsFiddle for this.
Update:
To make the panel not cover the sites content, add a margin to e.g. the body tag:
body {
margin-right: 100px;
}
The margin should be the width of your panel. jsFiddle

Resources