HTML text columns with different responsive padding in each column - html

I am helping out with some coding - which is not my fortay - and as part of a page, we are wanting to include and embed video and in a column to the right is a title for the video.
I am using HTML columns to allow them to show underneath each other on mobile. But because I want the title to show vertically aligned in the centre of the video, the responsive version has a big gap due to the I have had to use for the desktop version to look ok. I know this isn't the best way but I have tried using different padding in the .column styles, but because it appears to both, it's not giving me the look I need.
Is there any way of fixing this so there is a large padding on desktop but small-to-none on mobile?
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
}
</style>
</head>
<body>
<div class="row">
<div class="column">
<iframe src="VIDEO URL" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="column">
<center>
<br><br><br><br><br><br><p class="rtecenter"><p style="font-size:24pt; color:#0060a9;"><strong>VIDEO TITLE </strong></p>
</div>
</div>
</body>
</html>
Tried using the responsive style to add padding or trying to create a second column style but then the columns don't show floating next to each other.

Possibly do something like this?
What I did was got rid of all the <br> you used to manually "center" the title and simply added some CSS to style the row in order to align the items in the center, then kind of "undid" it in the media query by setting the row to inline-block
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
}
.row {
display: flex;
align-items: center;
}
/* Clear floats after the columns */
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
.row {
display:inline-block;
}
}
</style>
</head>
<body>
<div class="row">
<div class="column">
<iframe src="VIDEO URL" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="column">
<center>
<p class="rtecenter"><p style="font-size:24pt; color:#0060a9;"><strong>VIDEO TITLE </strong></p>
</center>
</div>
</div>
</body>
</html>

Related

Height not actually changing hieght while floating

Right now I'm coding a menu that has a two column layout. This is the code.
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>replit</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="stockapps">
<img src="icons/eShop.svg">
<img src="icons/sverse.svg">
</div>
<div class="main">
<p>
Hello!
</p>
</div>
</body>
</html>
CSS:
.stockapps {
background-color: #111;
float: left;
width: 5%;
height: 100%;
}
.stockapps :after {
content: "";
display: table;
clear: both;
}
.stockapps img{
width:100%;
display: inline;
vertical-align: top;
}
.main {
float: left;
padding: 2%;
width: 91%;
overflow: hidden;
}
The issue is that the stockapps div tag is not filling the whole screen with height instead opting to only fill the area the children objects take up.
I have tried using the clear-fix and setting overflow to hidden but neither seem to fix the issue. Its likely some beginner mistake as CSS is not my strong suit
This fiddle showcases the issue.
You can wrap stockapps and main divs into a container div
Style this container as below
I used background color for stockapps div to show you its height
.container {
display: flex;
align-items: stretch;
/*Set height as you want, you can use height in px */
height: 100vh;
}
.stockapps {
/* used background-color to show you how much height it takes*/
background-color: #999;
/*You can ignore width if it's not convenient for your desired final output */
width: 50%
}
<div class="container">
<div class="stockapps">
<img src="icons/eShop.svg">
<img src="icons/sverse.svg">
</div>
<div class="main">
<p>
Hello!
</p>
</div>
</div>
If I understand you correctly, you need to create a 2-column layout for your menu.
To achieve this layout, I would wrap the <div class="stockapps"> and <div class="main"> into another <div> with class of manu-wrap and add this CSS styles:
.menu-wrap {
display: flex;
justify-content: space-between;
}
I would then remove the float properties and you should have a working 2-column layout.
You can find more about display: flex here.

css - img and div sizing related to viewport

I'm attempting to create a webcomic style layout in HTML5 and CSS for personal learning. My goal is for the main-container class and all of its contents to fit inside the browser's viewport. The problem I'm encountering is that the image scales up at certain window sizes and the HTML that comes after the image is cut-off.
I've attempted to apply max-height and height values using the "vh" unit of measure in the main-container css. I can't seem to get it to work correctly. I've tried things mentioned on Stackoverflow (This and This), but none seem to produce the desired result. I'm thinking I'm missing something basic about the CSS behavior.
(if it matters, this practice image file is 800x500 in size by default).
Here is the code:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
img {
max-width: 100%;
height: auto;
}
.main-container {
display: flex;
flex-direction: column;
}
.comic-container {
display: flex;
flex-direction: column;
margin-left: 5%;
margin-right: 5%;
}
.comic-image {
object-fit: contain;
}
.comic-nav {
display: flex;
}
.f-center {
align-self: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="../css/comic.css" rel="stylesheet" />
</head>
<body>
<div class="main-container">
<h1 class="f-center">Site Title</h1>
<div class="comic-container">
<h4 class="f-center">Comic Title</h4>
<img src="../images/placeholder.png" alt="Comic Image" class="comic-image" />
<p class="f-center">Comic Text and Punchline</p>
<div class="f-center">
First |
Previous |
Next |
Last
</div>
</div>
<h6 class="f-center">Copyright ©XXXX - Person</h6>
</div>
</body>
</html>
Window-size shrunk, all contents fit
Window-maximized, contents cut off
Well, that's how flex boxes work in concordance with max-width/width set to 100%. The image will grow and will take the whole width of the flexed div/container.
display: flex;
flex-direction: column;
margin-left: 5%;
margin-right: 5%;
}
Technically, for your current display, you don't really need this. But if you want to keep it and restrict the image, you can either set a set width (i.e., 60%) for your image or have #media queries do the job of restyling the view accordingly.

Bootstrap 2 column 3 square layout doesn't fill page

I am having some issues with making my bootstrap layout fill the whole page. This is the jsbin for what I currently have: http://jsbin.com/tibusakuci/edit?html,css,output
I'm having trouble making the grid fill the entire page. I want it to look like this (filling the entire screen):
With it looking like this on mobile screens:
Does anyone have any ideas of why my code won't fill the whole screen when I take out the min-heights? Using bootstrap. Using height: 100% doesn't work either.
*Currently the boxes only fill half the screen
Thank you!
UPDATE: The follow code will fix your gutter issues. But it looks like your main issue is with the fluid container not filling the entire page.
CAUSE / SOLUTION: According to this github issue - Fluid Layout with 100% height #1671 - there is no "out of the box" solution. Try implementing one of the few solutions (with jsfiddle code) in that issue thread.
PREVIOUS ANSWER (partially obsolete)
Working jsbin: http://jsbin.com/rilihit/1/edit?html,css,output
STEPS
Remove the margin-bottom declaration from .row > div and from .sidebar-bottom.
Declare this css in your custom css file to remove the default bootstrap column gutter. This code is responsive and will work for all column sizes
.no-gutter > [class*='col-'] {
padding-right:0;
padding-left:0;
}
Finally, in your HTML, add the no-gutter to the rows like so.
Here's the complete HTML and CSS code. I modified your jsbin code and tested it. (I made the sidebar-bottom's min-height = 160px; so that the min-height values for the 2 add up to the min-height value for the content and nicely line up in desktop view. )
.row > div {
background-color: green;
}
.header,
.footer {
background: blue;
}
.content {
background: pink;
min-height: 300px;
}
.sidebar-top {
min-height: 140px;
background: yellow;
}
.sidebar-bottom {
min-height: 160px;
background: lightblue;
}
.no-gutter > [class*='col-'] {
padding-right: 0;
padding-left: 0;
}
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row no-gutter">
<div class="col-sm-7">
<div class="content"></div>
</div>
<div class="col-sm-5">
<div class="row no-gutter">
<div class="col-sm-12">
<div class="sidebar-top"></div>
</div>
</div>
<div class="row no-gutter">
<div class="col-sm-12">
<div class="sidebar-bottom"></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Related Reference / Reading: Bootstrap 3 Tips and Tricks You Still Might Not Know
Remove padding from the container-fluid and col-*. You can use vh for full hieght, and adjust this accordingly for 33% height on smaller screens.
.content {
background: pink;
min-height: 100vh;
}
.sidebar-top{
min-height: 50vh;
background: yellow;
}
.sidebar-bottom{
min-height: 50vh;
background: lightblue;
}
#media (max-width: 768px) {
.content,
.sidebar-top,
.sidebar-bottom {
min-height: 33vh;
}
}
.row.no-gutter {
margin-right:0;
margin-left:0;
}
.row.no-gutter > [class*='col-'],
.container-fluid {
padding-right:0;
padding-left:0;
}
Working demo: http://www.codeply.com/go/r3Rdffxi7A
remove padding and margin of surrounding, and remove the negative left and right shift.

iFrame Height Auto (CSS)

I am having problems with my iframe. I really want the frame to auto adjust heights according to the content within the iframe. I really want to do this via the CSS without javascript. However, I will use javascript if I have too.
I've tried height: 100%; and height: auto;, etc. I just don't know what else to try!
Here is my CSS. For the frame...
#frame {
position: relative;
overflow: hidden;
width: 860px;
height: 100%;
}
And then for the frame's page.
#wrap {
float: left;
position: absolute;
overflow: hidden;
width: 780px;
height: 100%;
text-align: justify;
font-size: 16px;
color: #6BA070;
letter-spacing: 3px;
}
The page's coding looks like this...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" �� "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>...</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
</div>
<div id="navigation">
home
about
fanlisting
100 reasons
letter
</div>
<div id="content" >
<h1>Update Information</h1>
<iframe name="frame" id="frame" src="http://website.org/update.php" allowtransparency="true" frameborder="0"></iframe>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Please note that the URL within the iframe is different then the website the iframe will be displayed on. However, I have access to both websites.
Can anyone help?
I had this same issue but found the following that works great:
The key to creating a responsive YouTube embed is with padding and a container element, which allows you to give it a fixed aspect ratio. You can also use this technique with most other iframe-based embeds, such as slideshows.
Here is what a typical YouTube embed code looks like, with fixed width and height:
<iframe width="560" height="315" src="//www.youtube.com/embed/yCOY82UdFrw"
frameborder="0" allowfullscreen></iframe>
It would be nice if we could just give it a 100% width, but it won't work as the height remains fixed. What you need to do is wrap it in a container like so (note the class names and removal of the width and height):
<div class="container">
<iframe src="//www.youtube.com/embed/yCOY82UdFrw"
frameborder="0" allowfullscreen class="video"></iframe>
</div>
And use the following CSS:
.container {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%;
}
.video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Here is the page I found the solution on:
https://www.h3xed.com/web-development/how-to-make-a-responsive-100-width-youtube-iframe-embed
Depending on your aspect ratio, you will probably need to adjust the padding-bottom: 56.25%; to get the height right.
This is my PURE CSS solution :)
Add, scrolling yes to your iframe.
<iframe src="your iframe link" width="100%" scrolling="yes" frameborder="0"></iframe>
The trick :)
<style>
html, body, iframe { height: 100%; }
html { overflow: hidden; }
</style>
You don't need to worry about responsiveness :)
#SweetSpice, use position as absolute in place of relative. It will work
#frame{
overflow: hidden;
width: 860px;
height: 100%;
position: absolute;
}
hjpotter92
Add this to your section:
<script>
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
And change your iframe to this:
<iframe src="..." frameborder="0" scrolling="no" onload="resizeIframe(this)" />
It is posted Here
It does however use javascript, but it is simple and easy to use code that will fix your problem.
<div id="content" >
<h1>Update Information</h1>
<div id="support-box">
<div id="wrapper">
<iframe name="frame" id="frame" src="http://website.org/update.php" allowtransparency="true" frameborder="0"></iframe>
</div>
</div>
</div>
#support-box {
width: 50%;
float: left;
display: block;
height: 20rem; /* is support box height you can change as per your requirement*/
background-color:#000;
}
#wrapper {
width: 90%;
display: block;
position: relative;
top: 50%;
transform: translateY(-50%);
background:#ddd;
margin:auto;
height:100px; /* here the height values are automatic you can leave this if you can*/
}
#wrapper iframe {
width: 100%;
display: block;
padding:10px;
margin:auto;
}
https://jsfiddle.net/umd2ahce/1/
You have to use absolute position along with your desired height.
in your CSS, do the following:
#id-of-iFrame {
position: absolute;
height: 100%;
}
You should note that div tag behaves like nothing and just let you to put something in it. It means that if you insert a paragraph with 100 lines of text within a div tag, it shows all the text but its height won't change to contain all the text.
So you have to use a CSS & HTML trick to handle this issue. This trick is very simple. you must use an empty div tag with class="clear" and then you will have to add this class to your CSS. Also note that your have #wrap in your CSS file but you don't have any tag with this id. In summary you have to change you code to something like below:
HTML Code:
<!-- Change "id" from "container" to "wrap" -->
<div id="wrap">
<div id="header">
</div>
<div id="navigation">
home
about
fanlisting
100 reasons
letter
</div>
<div id="content" >
<h1>Update Information</h1>
<iframe name="frame" id="frame" src="http://website.org/update.php" allowtransparency="true" frameborder="0"></iframe>
<!-- Add this line -->
<div class="clear"></div>
</div>
<div id="footer">
</div>
<!-- Add this line -->
<div class="clear"></div>
</div>
And also add this line to your CSS file:
.clear{ display: block; clear: both;}
According to this post
You need to add the !important css modifier to your height percentages.
Hope this helps.

Center contents of webpage

I want to "centerize" the text and contents of my webpage. Now I don't want to align the text to center, I still want a left alignment but I want significant margins on the left and right so that everything looks relatively center-ish. Can you show me the HTML/CSS to achieve this? THanks.
<html>
<head>
<style type="text/css">
body {
text-align: center; /* Center in IE */
}
#content {
text-align: left; /* reset text-align for IE */
margin: 0 auto; /* Center in other browsers */
width: 800px;
}
html {
overflow: -moz-scrollbars-vertical; /* Force vertical scrollbar in FF */
}
</head>
<body>
<div id="content">
content here
</div>
</body>
</html>
*UPDATE: I added some CSS that forces a vertical scrollbar in FF as per some comments below.
Create 3 columns on your page. All your text goes in the center column and can be left alligned.
Have a look here for examples http://matthewjamestaylor.com/blog/perfect-3-column.htm
#wrapper {
width: 800px;
margin: 0 auto;
}
<div id="wrapper">
<p>This will appear in a centered container</p>
</div>
I believe this might help you.
try
#div {
margin:0 auto
};
Have a container div within which you put all your content:
<html>
<head>
<title>a sample</title>
</head>
<body>
<div id="container">
<h1>this is it</h1>
<p>all content goes here</p>
</div>
</body>
Then add some css specifying the width and margins of your container div:
#container {
width: 750px;
margin: 0 auto;
}
CSS:
#container {
max-width: 800px;
margin: 0 auto;
}
And in the HTML, wrap everything in:
<div id='container'>
...
</div>
(Note that this answer differs from meep's in that I'm using max-width to give a fluid layout below 800 pixels, whereas he's using width to give a fixed layout.)