I am making an accordion menu whereby I am adding a PDF inside an object element. However I just cannot get the object to show 100% of its height, therefore it makes it difficult to use.
All I would like is to know how to make the PDF file inside of the object div to show it's full height. I remember having similar issues with footers..
Thanks.
if( jQuery(".toggle .toggle-title").hasClass('active') ){
jQuery(".toggle .toggle-title.active").closest('.toggle').find('.toggle-inner').show();
}
jQuery(".toggle .toggle-title").click(function(){
if( jQuery(this).hasClass('active') ){
jQuery(this).removeClass("active").closest('.toggle').find('.toggle-inner').slideUp(200);
} else {
jQuery(this).addClass("active").closest('.toggle').find('.toggle-inner').slideDown(200);
}
});
body {
color: #4B4B4B;
font-family: ARIMO;
}
body a {
cursor: pointer;
color: #4B4B4B;
text-decoration: none;
}
body section {
margin-bottom: 90px;
}
body section h1 {
text-transform: uppercase;
text-align: center;
font-weight: normal;
letter-spacing: 10px;
font-size: 25px;
line-height: 1.5;
}
object{
width: 100%;
height: 100%;
display: block;
position: relative;
min-height: 100%;
}
/* Styles for Accordion */
.toggle{
background: #eee;
border-top: solid 1px #3b7c8e;
margin-bottom: 50px;
width: 80%;
height: 100%;
}
.toggle .toggle-title {
position: relative;
display: block;
margin-bottom: 6px;
}
.toggle .toggle-title h3 {
font-size: 20px;
margin: 0px;
line-height: 1;
cursor: pointer;
font-weight: 200;
}
.toggle .toggle-inner {
padding: 7px 25px 10px 25px;
display: none;
margin: -7px 0 6px;
max-width: 100%;
max-height: 100%;
min-height: 100%;
}
.toggle .toggle-inner div {
max-width: 100%;
max-height: 100%;
min-height: 100%;
}
.toggle .toggle-title{
display: block;
padding: 25px 25px 14px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="toggle">
<div class="toggle-title">
<h3>
<div class="title-name">Example title</div>
</h3>
<p>Example call for paper</p>
<p>Astronomers face an embarrassing conundrum: they don't know what 95% of the universe is made of. Atoms, which form everything we see around us, only account for a measly 5%. Over the past 80 years it has become clear that the substantial remainder is comprised of two shadowy entities – dark matter and dark energy. The former, first discovered in 1933, acts as an invisible glue, binding galaxies and galaxy clusters together. Unveiled in 1998, the latter is pushing the universe's expansion to ever greater speeds. Astronomers are closing.</p>
</div>
<div class="toggle-inner">
<object height="100" data="http://prototypes.infopro-insight.com/test/MW/call_for_papers.pdf"></object>
</div>
</div><!-- END OF TOGGLE -->
Related
I am making a copy of The Boring Company website to get a bit practise and I ran into a text problem.
The site consists of one section that contains a header with nav and below the header, there is a div that contains a title and some text. The problem is that upon resizing the browser window, the text starts getting pushed inside the header.
How the site normally looks
How it looks after resizing the browser window
Is there any way to prevent this, please? Thanks in advance!
/* GENERAL */
* {
padding: 0;
margin: 0;
}
body, html {
height: 100%;
}
body {
box-sizing: border-box;
}
img {
max-width: 100%;
height: auto;
}
.layout {
background: rgba(0, 0, 0, 0.37);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/* SECTIONS */
main, section {
box-shadow: inset 0px -40px 50px 30px #000000;
height: 100Vh;
position: relative;
padding-top: -1px;
color: white;
}
.tunnels2-section {
background: url("/IMGs/tunnels2-section.jpg");
background-size: cover;
background-attachment: fixed;
background-position: center;
}
/* HEADER AND NAV */
header {
background: black;
padding: 0.1em;
}
nav {
display: flex;
align-items: center;
justify-content: space-between;
margin: 1em 5em;
font-family: 'Ropa Sans', sans-serif;
font-weight: bold;
}
.burger {
position: absolute;
right: 1%;
top: 2%;
display: none;
}
.burger div {
width: 25px;
height: 2px;
margin: 5px;
background-color: white;
border: 1px solid black;
}
.main-nav-items {
display: flex;
align-items: center;
}
.main-nav-item, .side-nav-item {
display: inline-block;
margin: 0em 0.6em;
}
li a {
color: white;
text-decoration: none;
}
/* MAIN CONTENT */
.boring-company-info {
position: absolute;
bottom: 28%;
margin: 0em 6em;
font-size: 0.7em;
font-family: "Roboto", sans-serif;
color: white;
opacity: 1;
transition: 0.5s ease;
transform: translateY(20px);
}
h2 {
margin-bottom: 0.2em;
}
.info-title {
font-size: 3em;
font-weight: 600;
margin-bottom: 0.65em;
}
.info-description {
line-height: 20px;
font-size: 1.55em;
font-weight: 500;
width: 55%;
}
.tunnels-info-description {
font-size: 1.38em;
font-weight: 100;
line-height: 22px;
width: 65%;
}
b {
font-weight: 700;
}
#media screen and (max-width: 915px) {
.burger {
display: block;
}
.main-nav-item a, .side-nav-item a {
display: none;
}
nav {
margin: 0;
}
.boring-company-desc {
margin: 0em 2em;
}
h2 {
margin-top: 0.7em;
}
}
#media screen and (max-width: 641px) {
.boring-company-info {
margin: 0em 2em 0em;
}
/* This fixes the issue, but only temporarily. It still overflows to
the header above it. */
.info-description {
width: 100%;
}
}
<section class="tunnels2-section">
<div class="layout">
<header>
<nav>
<ul class="main-nav-items">
<li class="main-nav-item"><img src="IMGs/company-logo.png" width=115px class="company-logo" alt="Logo of the Boring Company"></li>
<li class="main-nav-item">TUNNELS</li>
<li class="main-nav-item">PRODUCTS</li>
<li class="main-nav-item">PROJECTS</li>
<li class="main-nav-item">PRUFROCK</li>
<li class="main-nav-item">LOOP</li>
</ul>
<ul class="side-nav-items">
<li class="side-nav-item">CAREERS</li>
<li class="side-nav-item">FLAMETHROWER</li>
</ul>
<div class="burger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</nav>
</header>
<div class="boring-company-info" id = "why-tunnels">
<h1 class="info-title">WHY TUNNELS?</h1>
<p class="tunnels-info-description info-description"><b>Solve traffic: </b>to solve the problem of soul-destroying traffic, roads must go 3D. Surface roads today incorporate 3D model-like elevated highways and cloverleaf interchanges that are expensive and disruptive to build. Tunneling networks are 3D and provide high-throughput transportation in an economically viable way. Traffic and congestion will be a thing of the past. </p>
<p class="tunnels-info-description info-description"><br><b>Beautify our cities:</b> existing transportation networks occupy valuable space in cities where land availability is scarce. Tunnels minimize usage of surface area and could move entire transportation networks underground. Taking transportation underground allows us to repurpose roads into community-enhancing spaces, and beautify our cities.</p>
<p class="tunnels-info-description info-description"><br><b>Enable HyperLoop:</b> Hyperloop networks unlock high-speed regional transportation surpassing other alternatives. Hyperloop enables access to individualized, point to point high-speed transportation.</p>
</div>
</div>
</section>
You will need to add this to the appropriate breakpoint.
main, section {height: auto;}
I would try to avoid using position: absolute on the .boring-company-info class as that can create theses sorts of conflicts.
If you're looking to position it on the page in a certain way, consider adjusting the padding or margins of the elements on the page or look into using flex. https://css-tricks.com/snippets/css/a-guide-to-flexbox/
I am trying to create a part of my website,
Here is the code:
import React from 'react';
import './stylesheets/BeyondHelloWorld.css';
import BHW from './assets/bhw.png';
function BeyondHelloWorld() {
return (
<div className="mainDiv">
<div className="card">
<div className="cardContainer">
<div style={{height: "100%", display: "block"}}>
<img src={BHW} className="bhwImage"/>
</div>
<div class="bhwText">
<span className="bhwTitle">BeyondHelloWorld</span>
<span className="fadedTitle">Beyond</span>
<span className="bhwDescription">BeyondHelloWorld is a learning community for budding programmers. It is aimed at equipping amateurs with easy knowledge of the tech world through engaging content like New Tech information, tips & tricks & BTS of a developers life!</span>
<span className="bhwDescription">A lot of community problems can be solved using technology. BeyondHelloWorld aims to influence non-programmers into the world of programming.</span>
</div>
</div>
</div>
</div>
)
}
export default BeyondHelloWorld
If you see the span bhwDescription, it is inside bhwText div which is inside cardContainer.
Now I have a picture on the left with classname bhwImage
When the text exceeds the height of this image, the text starts from the left of the cardContainer, but I want it to start from the starting edge of the bhwText.
Example:
But with my code, What it looks like:
What am I doing wrong?
Also, if you notice, the fadedTitle and bhwTitle are not exactly aligned. I want them all to start where the picture starts. But something is going off. Even if I keep the padding/margin same, even then they have different starts.
Here is the css:
.mainDiv {
width: 100%;
padding: 50px;
background-color: #1e3512;
}
.card {
background-color: #1e3512;
box-shadow: 5px 5px 20px 0px rgba(0, 0, 0, 0.48);
padding: 0;
overflow: hidden;
}
.cardContainer {
margin: 0;
padding: 0 20px 0 0;
width: 100%;
}
.bhwImage {
height: 18vh;
object-fit: contain;
margin: 40px;
border: 5px solid #fff;
float: left;
}
.bhwText {
margin-top: 20px;
color: #ffffff;
}
.bhwTitle {
font-size: 3.5rem;
font-weight: 600;
display: block;
margin-bottom: 20px;
}
.fadedTitle {
position: absolute;
top: 25px;
font-size: 150px;
line-height: 75px;
opacity: 0.1;
font-weight: 900;
}
.bhwDescription {
display: block;
margin-bottom: 20px;
font-size: 1.8rem;
font-weight: 500;
word-wrap: break-word;
}
Add display:flex to your .cardContainer class
.cardContainer {
margin: 0;
padding: 0 20px 0 0;
width: 100%;
display: flex;
}
and remove width:100% from .mainDiv class
.mainDiv {
/* width: 100%; */ remove this
padding: 50px;
background-color: #1e3512;
display: flex;
}
Live Demo
The reason why the content runs underneath the image is because its style is float: left;, and your .bhwText class has a width of 100% because it's a block element. div elements are generally display: block; by default. This means .bhwText width is 100% of the parent container by default. The text will fill up space where available in it's container; including below the image.
To fix this issue, add left padding to the .bhwText class. Something like this example here.
.bhwText {
margin-top: 20px;
color: #ffffff;
padding: 0 0 0 200px;
}
I'm working on a little design for a site that's comprised of the main content being in a square roughly 80% the width of the site, and then a header, footer and two sidebars being signalled via lines. I have the header, footer, lines and content all working, and they all (mostly) stay in the right place when resized. However, I can't for the life of me work out how to get the square in the center to continue to fill the section in the middle of the screen (without overlapping, or having a scroll bar!)
I've attached the code for my square and some screenshots of what I'm attempting to do and what currently happens below. Other than my innercontent div, there're no divs on the side, and a header and footer div above and below.
*Update: Added code as requested. I believe this is all that's used in the example I provided in the screenshots, other than the lines, which are produced via some JS. I've included the important css here too, so to allow me to link to my JS Fiddle with it all:
/* ===================
Inital Styles
=================== */
html {
color: #fff;
font-size: 1em;
background: #3f51b5;
line-height: 1.4;
animation: fade 5s
}
::-moz-selection {
background: #6534ff;
text-shadow: none;
}
::selection {
background: #3f51b5;
text-shadow: none;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
audio,
canvas,
iframe,
img,
svg,
video {
vertical-align: middle;
}
fieldset {
border: 0;
margin: 0;
padding: 0;
}
textarea {
resize: vertical;
}
.browserupgrade {
margin: 0.2em 0;
background: #ccc;
color: #000;
padding: 0.2em 0;
}
body {
font: 16px/26px Helvetica, Helvetica Neue, Arial;
}
h1,
h2,
h3,
h4 {
color: #fff;
font-family: 'Montserrat', sans-serif;
line-height: normal;
}
h1 {
font-size: 25px;
letter-spacing: 3.1;
}
h2 {
font-size: 14px;
font-weight: 500;
text-align: justify;
}
h3 {
font-family: 'Space Mono', monospace;
font-weight: 400;
}
h4 {
font-size: 19px;
}
.inline {
display: inline;
}
.clear {
clear: both;
display: block;
content: "";
}
.center {
margin: auto;
width: 50%;
padding: 10px;
}
.header-container {
height: 145px;
position: relative;
}
.header-center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.title {
color: white;
text-align: center;
font-size: 40px;
font-family: 'Space Mono', monospace;
font-weight: 400;
line-height: 0px;
margin-top: 35px;
}
.subTitle {
color: white;
text-align: center;
font-size: 14px;
font-family: 'Space Mono', monospace;
font-weight: 400;
font-style: italic;
}
.innercontent {
position: relative;
height: 3vw;
width: 80%;
margin: auto;
padding-top: 32.5vw;
margin-top: -28px;
margin-left: 10.0%;
}
.green {
background: #42ab9e;
}
/* ===================
Name Collection
=================== */
#nameCollection {
text-align: center;
}
#nameText {
margin-top: -28%;
margin-left: 15%;
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
}
.nameSkipButton {
margin-top: 25px;
background-size: 210% 100%;
background-image: linear-gradient(to right, #963019 50%, #16174f 50%);
-webkit-transition: background-position 0.3s;
-moz-transition: background-position 0.3s;
transition: background-position 0.3s;
border: none;
font-family: 'Space Mono', monospace;
color: #fff;
padding: 10px;
font-size: 12px;
}
.nameSkipButton:hover {
background-position: 99%, 0;
}
<body>
<div class="delay">
<div class="fade-in delay">
<div class="header-container">
<header class="header-center">
<h1 class="title" onclick="location.reload();" style="cursor: pointer;">COMPUTERIFY.IO</h1>
<p class="subTitle" onclick="location.reload();" style="cursor: pointer;">Alpha is just a fancy word for unfinished.</p>
<p class="subTitle">
</h1>
</header>
</div>
<div class="main-container">
<div id="content" class="innercontent green">
<div id="nameCollection">
<div id="nameText">
<h3>Hello. I'm the PC Generator, or PCG for short. Before we get started, can I just ask...</h3>
<h1>What's your first name?</h1>
<div>
<input type="button" style="display:none" id="btnSearch" value="Search" onclick="getUserName()" />
<span class="input input--nameCollection">
<input class="input__field input__field--nameCollection" maxlength="19" onkeydown = "if (event.keyCode == 13) document.getElementById('btnSearch').click()" type="text" id="input-25" />
<label class="input__label input__label--nameCollection" for="input-25">
<span class="input__label-content input__label-content--nameCollection">First Name</span>
</label>
</span>
</div>
<input class="nameSkipButton" id="skipName" type="button" value="I don't value my name, pick one for me" onclick="confirmSkip();" />
</div>
</div>
</div>
</div>
</div>
https://jsfiddle.net/nxyg4a9x/2/
Attached screenshots demonstrating the design when it works (on a 1920x1080 display, and how it looks on resize and on mobile.
I would use flexbox if you can.
The following is a demo and you'll likely need to make adjustments to fit your needs.
* {
box-sizing: border-box;
}
body {
display: flex;
flex-direction: column;
margin: 0;
min-height: 100vh;
overflow: hidden;
background-color: #3f51b5;
}
header,
main,
footer {
margin: 0 10%; // Indirect way of making element width: 80%;
border-left: 2px solid lightgray;
border-right: 2px solid lightgray;
}
header,
footer {
flex-basis: 100px;
}
main {
position: relative;
flex-grow: 1;
background-color: #42ab9e;
}
main:before {
content: '';
z-index: -1;
position: absolute;
top: -2px;
right: -100%;
bottom: -2px;
left: -100%;
display: block;
border-top: 2px solid lightgray;
border-bottom: 2px solid lightgray;
}
<header></header>
<main></main>
<footer></footer>
The most important thing that we did is use flex-grow: 1 on main which addresses your primary concern of stretching your content area to fill the appropriate space. flex-grow: 1 tells the element to take up any remaining space inside of it's parent element. So whatever space is left over from the height of the header and footer it will file up.
We use min-height on body as a starting point so that main doesn't end up a fixed size (which is what would have happened if we used height instead) and the layout fills the viewport initially even if there is not a lot of content.
You mentioned using JS to create your lines, that seems like overkill to me and can be accomplished with CSS. The lines are just borders and the only non obvious set of lines would be the horizontal lines that extend outside of main. I did this with a pseudo element that stretches itself outside of it's parent element. The top and bottom of the pseudo element are pulled outside of it's containing element equal to the border's thickness. The left and right of the pseudo element are pulled out just wide enough to always extend a little past the viewport window (I used a relative unit so it will grow with the viewport). We used overflow: hidden; on body to prevent a horizontal scrollbar that this element initially creates.
Hope this works for you and let me know if you have any questions, cheers!
In your .innercontent div, you are using the vw measurement which stands for "viewport width" - basically what this means is that the height of your box is going to be relative to the width of the screen/viewport that the user is viewing the site in.
You need to set height, width margin etc in another unit other than vw since it will result in what you're seeing. I forked your fiddle to demonstrate.
https://jsfiddle.net/550n5wgn/1/
As part of my HTML5/CSS3 app, I need to implement zoomable image popup. When the user clicks on a small image, a full-screen popup appears containing that image in the middle with a title above it and a button to close the popup below it. Clicking on the image then removes any scaling and puts it full-size inside a box in the middle to allow scrolling - with title and "close" button staying above and below.
I'm using flex (for several reasons, including vertical centering content). The overall popup works and looks fine. Clicking on the image does increase it in size, but it resizes the box so that the "done" button is pushed below the overall popup.
Here's the jsfiddle demonstrating the issue
I don't mind the fact that the box resizes - the more room to view/scroll the larger image - but I need to ensure that the button at the bottom stays put relative to the bottom edge of the popup.
My HTML looks like this (I used a random image for demonstration):
<div id="overlay" class="hidden">
<div id="alsg">
<div class="intro">Assist with ALS</div>
<div class="box scrollable">
<img src="http://upload.wikimedia.org/wikipedia/commons/8/8c/Male_monarch_butterfly.JPG" class="fit" />
</div>
<div class="popup-buttons">
<div id="button-alsg-done" class="button button-state-action button-green right">Done</div>
<div class="clear"></div>
</div>
</div> <!-- alsg -->
</div>
With the javascript being
$('img', '#alsg').on('click', function(e) {
$(this).toggleClass('fit');
});
There's a lot of CSS, unfortunately. You'll note that there's a pretty bad mix of flex and old-school positioning. This is because the app initially didn't use flex at all and I'm in a slow process of migrating/cleaning up now.
div#overlay {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
z-index: 104;
display: flex;
align-items: center;
justify-content: center;
}
div#overlay > div {
position: relative;
width: calc(100% - 40px);
margin: 10px auto;
background-color: #A9A9A9;
border-radius: 8px;
text-align: center;
padding: 10px;
display: flex;
flex-direction: column;
}
div#alsg {
max-height: calc(100% - 40px) !important;
}
div#overlay div.intro {
color: #FFF !important;
font-size: 12pt;
margin-bottom: 10px;
}
div#overlay div.box, div.template div.box {
padding: 3px 5px;
overflow: hidden;
font-weight: bold;
position: relative;
flex-grow: 1;
}
div#alsg div.box {
text-align: center;
position: relative;
overflow: auto !important;
margin: 10px 0px 0px !important;
}
div.box {
background-color: #FFF;
color: #27374A;
border-radius: 8px;
border: 3px solid #FBE96E;
position: relative;
margin: auto;
flex-shrink: 1;
}
.fit {
max-width: calc(100% - 4px) !important;
max-height: calc(100% - 4px) !important;
}
div.popup-buttons {
margin-top: 10px;
}
#overlay .button.right {
margin-left: 10px;
}
#button-alsg-done {
margin-top: 10px;
flex-basis: 25px;
}
div.button-green {
background-color: #2CC55D;
color: #FFF;
font-weight: bold;
}
div.button-state-action {
height: 25px;
padding: 0px 5px;
line-height: 25px;
text-align: center;
border-radius: 4px;
font-size: 10pt;
font-weight: normal !important;
width: 60px;
cursor: pointer;
margin-bottom: 5px;
}
div.button {
height: 22px;
padding: 0px 2px;
line-height: 22px;
text-align: center;
border-radius: 4px;
font-size: 9pt;
width: 42px;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
}
.right {
float: right;
}
.clear {
clear: both;
}
I am trying to center the flame and the heading to the middle of the white box.
HTML
<div class="contentheading">
<div class="floatmiddle">
<img src="images/flame45x45.png">
<h3>Receive only the email you want.</h3>
</div>
</div>
CSS
.contentheading {
position: relative;
height: 45px;
margin-top: 30px;
width: 636px; //this is the full width of the white box//
}
.floatmiddle {
margin: 0 auto;
height: 45px;
display: block;
}
.contentheading img {
position: absolute;
}
.floatmiddle > h3 {
font-family: "signika";
font-size: 22px;
font-weight: 500;
color: #37434f;
height: 45px;
line-height: 45px;
margin: 0 0 0 60px;
text-align: center;
vertical-align: top;
position: absolute;
}
I need the .float middle to inherit the width of the two enclosing elements - the image (45 x 45px) and the text (which will be different length for each chapter i have) so i need one class/formula so i can just go through and pop in the headings and no matter the headings length the heading and the fireball will be centered within the white div.
You can use display: inline-block; to center this div.
http://jsfiddle.net/d8gyd9gu/
HTML
<div class="contentheading">
<div class="floatmiddle">
<img src="http://www.neatimage.com/im/lin_logo.gif" alt="">
<h3>Receive only the email you want.</h3>
</div>
</div>
CSS
.contentheading {
height: 45px;
margin-top: 30px;
width: 636px;
text-align: center;
}
.floatmiddle {
height: 45px;
display: inline-block;
}
.contentheading img {
float: left;
margin: 20px 10px 0px 0px;
}
.floatmiddle > h3 {
font-family: "signika";
font-size: 22px;
font-weight: 500;
color: #37434f;
height: 45px;
line-height: 45px;
padding: 0px 0px 0px 60px;
}
If you can use flexbox you can do it really simply like this:
.contentheading {
border: 1px dashed #ff0000;
margin-top: 30px;
width: 636px;
display: flex;
justify-content: center;
align-items: center;
}
.contentheading h3 {
font-family: "signika";
font-size: 22px;
font-weight: 500;
color: #37434f;
}
<div class="contentheading">
<img src="images/flame45x45.png" width="45" height="45" />
<h3>Receive only the email you want.</h3>
</div>
If you need to support older browsers make sure you add the prefixed versions.
You can definitely pare your markup and styling down. If you only need to center the text and the image in a div of a fixed width, you can simply use text-align: center on the parent container, and display: inline-block on the two elements within. The following markup and styling is about as little as you need:
HTML
<div class="content-heading">
<img src="images/flame45x45.png">
<h3>Receive only the email you want.</h3>
</div>
CSS
.content-heading {
background-color: #ccc;
height: 45px;
margin: 0 auto; /** Centers on the page **/
text-align: center;
width: 636px;
}
h3 {
display: inline-block;
line-height: 45px; /** Only really works if you can rely on only displaying one line of text **/
margin: 0;
overflow: hidden; /** Need this to keep inline-block elements from staggering **/
padding: 0;
}
img {
background-color: black; /** Purely so we can see this **/
display: inline-block;
height: 45px;
width: 45px;
}
That's really all you need.
Codepen sketch