I'm trying to create a layout similar to the one shown here. However I'm quite confused on how to successfully get something like this to work. I've attempted a number of solutions and options, all which have failed to do what I've drawn here. Are their any layout guru's out there that could help me achieve this look. The key here are getting the sticky areas to remain sticky and the scroll areas to have their scroll bars. Where I struggle is getting the divs to always expand to take up the vertical space remaining. The sidebar on the right can be a fixed width, however the rest is flexible to take up available space.
Desired results
This is what I have so far. The top bar is sticky as desired, but the individual scroll bars are not displaying for the two columns, unless I hard code a fixed height for the column divs. Which in my case i want them to take as much vertical space as possible.
DetailsPage.vue
<template>
<q-page class="flex" style="background: grey">
<div
class="col q-pa-md scroll"
style="background: rgba(240, 150, 50, 0.75); height:400px;"
>
{{ dummyText }}
</div>
<div
class="col-4 q-pa-md scroll"
style="
background: rgba(130, 140, 180, 0.75);
min-width: 200px;
max-width: 200px;
height:400px;
"
>
{{ dummyText }}
</div>
</q-page>
</template>
Current Results
You can use scroll-area and dynamic height accordingly. Please refer the following code.
<q-page class="flex" style="background: grey">
<div
class="col q-pa-md"
style="background: rgba(240, 150, 50, 0.75);"
>
<q-scroll-area
style="height: 87vh;"
>
<div v-for="n in 100" :key="n" class="q-pa-xs">
Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.
</div>
</q-scroll-area>
</div>
<div
class="col-4 q-pa-md "
style="
background: rgba(130, 140, 180, 0.75);
min-width: 200px;
max-width: 200px;
"
>
<div class="q-pa-xs">
Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.
</div>
<q-scroll-area
style="height: 65vh;"
>
<div v-for="n in 100" :key="n" class="q-pa-xs">
Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.
</div>
</q-scroll-area>
</div>
</q-page>
Related
I've a slightly odd requirement here. I'm trying to create a HTML + CSS transcript of a seventeenth century book which has a peculiar layout. The pages have a column of text with a generous right-hand margin that contains various floats (many of which are tables of numbers). These floating diagrams line up with the paragraphs of text so that the first line of the float lines up with the last line of the paragraph. (The text makes reference to this fact, so it's important to preserve it.)
Mostly this is easy, as in this example:
<main>
<h1>Test</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua —
<span class="float">123<br/>456</span></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua —
<span class="float">789</span></p>
</main>
main {
max-width: 475px;
padding: 0.5rem;
border: thin solid black;
margin: 0 auto;
}
h1 {
text-align: center;
}
p {
text-align: justify;
text-indent: 1.5em;
padding-right: 0.5rem;
border-right: thin solid black;
margin: 0 calc(3ch + 0.5rem) 0 0;
}
span.float {
float: right;
clear: right;
text-align: right;
text-indent: 0;
font-variant-numeric: tabular-nums;
width: calc(3ch);
margin-right: calc(-3ch - 1rem);
}
This produces something like the following, which is exactly as I want:
The 123 lines up with the end of the first paragraph, the 789 lines up with the end of the second paragraph, and the first float (123, 456) flows alongside the start of the second paragraph.
However, very occasionally, I have a large float and the following paragraph is very short, e.g.
<main>
<h1>Test</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua —
<span class="float">123<br/>456<br/>789</span></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit
sed do eiusmod tempor incididunt — <span class="float">321</span></p>
<p>Lorem ipsum dolor sit amet.</p>
</main>
(CSS as before.) If this happens, the book adds space above the second paragraph, and I want to replicate this so that it looks a bit like the following (which I've mocked up by inserting <p><br/></p> before the second paragraph):
Is there a way of achieving this in HTML and CSS? I'm not adverse to changing the way I mark up the document, however I'm catering for a variety of screen widths and fonts, so I cannot hard-code spacing based on how much I need in my browser. I'm happy with a solution that won't work in ancient browsers.
Update: To help illustrate what I'm after, here is a quick and dirty solution using jQuery, though I would prefer to avoid using Javascript if at all possible and do it in CSS:
$(function() {
$('p').each( function() {
var floats = $(this).find('.float');
var nextp = $(this).next('p:has(.float)');
if (floats.length && nextp.length) {
var f = $(floats[floats.length-1]), n = $(nextp[0]);
if (f.height() > n.height()) {
f.css('float', 'none');
n.css('padding-top', (f.height() - n.height()) + 'px');
f.css('float', 'right');
}
}
});
});
This question already has answers here:
HTML colspan in CSS
(16 answers)
Closed 3 years ago.
I have already tired to fix the colspan in the display table in CSS.
.table {
display: table;
table-layout: fixed;
width: 100%;
border-collapse: collapse;
}
.table-row {
display: table-row;
border-collapse: collapse;
}
.table-cell {
display: table-cell;
padding: 5px;
border: 1px solid black;
}
.table-row.colspan {
display: block;
}
.table-row.colspan .table-cell {
display: block;
width: 200%;
box-sizing: border-box;
}
<div class="table">
<div class="table-row">
<div class="table-cell">
top left cell
</div>
<div class="table-cell">
top right cell
</div>
<div class="table-cell">
top right cell
</div>
<div class="table-cell">
top right cell
</div>
<div class="table-cell">
top right cell
</div>
<div class="table-cell">
top right cell
</div>
</div>
<div class="table-row">
<div class="table-cell colspan">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="table-cell colspan">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="table-cell colspan">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
<div class="table-row">
<div class="table-cell">
bottom left cell
</div>
<div class="table-cell">
bottom right cell
</div>
<div class="table-cell">
bottom left cell
</div>
<div class="table-cell">
bottom right cell
</div>
<div class="table-cell">
bottom left cell
</div>
<div class="table-cell">
bottom right cell
</div>
</div>
</div>
How can I take the colspan behavior of the second row in the table? Thanks in advance.
https://codepen.io/mdshohelrana/pen/WNNxBqP
What do you mean with "colspan behaviour"?
It's not possible to reproduce the HTML colspan attribute in tables in CSS und display: table-*, because it's a structural thing not a style thing. Plus colspan requires a number parameter to determine the number of columns to span, which you don't have.
What are you trying to do anyway? If you want to use a table (for tabular data) then use HTML table/tr/td elements and the colspan attribute.
If you want to have a table like (page) layout, then you should be using css grid with which you can do colspan-like designs.
In any case you shouldn't be alot of divs and using class names such as table-row/celletc. Class names should semantically describe the content not the look of elements.
The issue was discussed here
There is no simple CSS property that we can provide for colspan (As far as I know).
I think using table tag is more efficient and understandable.
<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
<tr>
<td colspan="2">Sum: $180</td>
</tr>
</table>
https://www.w3schools.com/tags/att_td_colspan.asp You can refer here.
Well you can solve it by two approaches:
Use display:table-row-group and then for cell specify display:table-caption. but I am struggling with setting border on right side in this case.
Fiddle for same is below:
http://jsfiddle.net/hsbokxv4/
You can manipulate using javascript. Fiddle is below (Though I am not fan of this approach):
http://jsfiddle.net/emilianolch/5nvxv5ko/
I could simulate a hack with setting float and width. Maybe it can be used in your design. But I'm not sure if it'll work the same on all platforms. Adding a width to the whole table and setting the colspan width the same with the table would be a bit more secure for this. Updated the answer with the width set.
The important part for width's to match is the box-sizing: border-box setting. As it would differ the gaps between two cells and one cell in a row, this should be set.
.table {
display: table;
table-layout: fixed;
width: 600px;
border-collapse: collapse;
box-sizing: border-box;
}
.table-row {
display: table-row;
border-collapse: collapse;
box-sizing: border-box;
}
.table-row.colspanned
{
float: left;
margin: -1px 0;
width: 600px;
}
.table-cell {
display: table-cell;
padding: 5px;
border: 1px solid black;
box-sizing: border-box;
}
.table-cell.colspan {
margin-top: -1px;
margin-bottom: -1px;
width: 200px !important;
}
<div class="table">
<div class="table-row">
<div class="table-cell">
top left cell
</div>
<div class="table-cell">
top right cell
</div>
<div class="table-cell">
top right cell
</div>
<div class="table-cell">
top right cell
</div>
<div class="table-cell">
top right cell
</div>
<div class="table-cell">
top right cell
</div>
</div>
<div class="table-row colspanned">
<div class="table-cell colspan">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="table-cell colspan">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="table-cell colspan">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
<div class="table-row">
<div class="table-cell">
bottom left cell
</div>
<div class="table-cell">
bottom right cell
</div>
<div class="table-cell">
bottom left cell
</div>
<div class="table-cell">
bottom right cell
</div>
<div class="table-cell">
bottom left cell
</div>
<div class="table-cell">
bottom right cell
</div>
</div>
</div>
I'm brushing up on Responsive Grid CSS on YouTube. Following along with the instructors lesson. I'm having trouble formatting my nave grid. I've included both the html and css code along with pictures of his nav results vs mine. Any help would be appreciated.
I'm trying to get the navigation bar in a 4 column grid. I'm trying to see what I'm missing here.
Instructor Results:
My Results:
/* CSS Variables */
:root {
--primary: #ddd;
--dark: #333;
--light: #fff;
--shadow: 0 1px 5px rgba(104, 104, 104, 0.8);
}
html {
box-sizing: border-box;
font-family: Arial, Helvetica, san-serif;
color: var(--dark);
}
body {
background: #ccc;
margin: 30px 50px;
line-height: 1.4;
}
.btn {
background: var(--dark);
color: var(--light);
padding: 0.6rem 1.3rem;
text-decoration: none;
border: 0;
}
img {
max-width: 100%;
}
.wrapper {
display: grid;
grid-gap: 20px;
}
/* Navigation */
.main-nav ul {
display: grid;
grid-gap: 20px;
padding: 0px;
list-style: none;
grid-template-columns: repeat(4, 1fr);
}
<div class="wrapper">
<!-- Navigation -->
<nav class="main-nav">
<ul>
<li><a href="#">Home</li>
<li><a href="#">About</li>
<li><a href="#">Services</li>
<li><a href="#">Contact</li>
</ul>
</nav>
<!-- Top Container -->
<section class="top-container">
<header class="showcase">
<h1>Damn That Looks Delicious</h1>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Aliquam sem et tortor consequat id porta.
</p>
Read More
</header>
<div class="top-box top-box-a">
<h4>Membership</h4>
<p class="price">$199/mo</p>
Buy Now
</div>
<div class="top-box top-box-b">
<h4>Pro Membership</h4>
<p class="price">$299/mo</p>
Buy Now
</div>
</section>
<!-- Boxes Section -->
<section class="boxes">
<div class="box">
<i class="fas fa-pizza-slice fa-4x"></i>
<h3>Restaurants</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
</div>
<div class="box">
<i class="fas fa-utensils fa-4x"></i>
<h3>Chefs</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
</div>
<div class="box">
<i class="fas fa-hamburger fa-4x"></i>
<h3>Catering</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
</div>
<div class="box">
<i class="fas fa-ice-cream fa-4x"></i>
<h3>Sweets</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
</div>
</section>
<section>
<img src="images/dtld.jpg" alt="">
<div>
<h2> Your Business On DTLD</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Learn More
</div>
</section>
<!-- Portfolio Section -->
<section class="portfolio">
<img src="https:/source.unsplash.com/random/200x200" alt="">
<img src="https:/source.unsplash.com/random/201x200" alt="">
<img src="https:/source.unsplash.com/random/202x200" alt="">
<img src="https:/source.unsplash.com/random/203x200" alt="">
<img src="https:/source.unsplash.com/random/204x200" alt="">
<img src="https:/source.unsplash.com/random/205x200" alt="">
<img src="https:/source.unsplash.com/random/206x200" alt="">
<img src="https:/source.unsplash.com/random/207x200" alt="">
<img src="https:/source.unsplash.com/random/208x200" alt="">
</section>
<!-- Footer -->
<footer>
<p> Damn That Looks Delicious © 2005</p>
</footer>
</div>
<!-- Wrapper Ends -->
Once you add the closing tag to your anchor elements the layout works as you expect.
This is what you have now:
.main-nav ul {
display: grid;
grid-gap: 20px;
padding: 0px;
list-style: none;
grid-template-columns: repeat(4, 1fr);
}
<nav class="main-nav">
<ul>
<li><a href="#">Home</li>
<li><a href="#">About</li>
<li><a href="#">Services</li>
<li><a href="#">Contact</li>
</ul>
</nav>
Because the anchor elements are left open (creating invalid HTML code), the browser generates four additional grid items. Now the grid container has eight children: 4 li and 4 a.
Since your code allows for only four items per row, a second row is created to accommodate the other four items. In fact, you always had a four-column grid.
Once you close the anchor tags (creating valid HTML code), only four grid items are rendered.
.main-nav ul {
display: grid;
grid-gap: 20px;
padding: 0px;
list-style: none;
grid-template-columns: repeat(4, 1fr);
}
<nav class="main-nav">
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</nav>
Also, you may want to see my answer here for a brief analysis and suggestion regarding unordered lists inside nav elements.
There is missing of closing anchor </a> tag in your code so once you add closing anchor tag in it. Your code will run perfectly.
screenshot of missing anchor tag
Between:
<h2>Menu</h2>
and
<h5>Hover to see more!</h5>
I have this huge gap, is there a way to remove it?
For more references this is my code before heading 2:
<div class="container">
<img src="Lato Font Test.png" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><p>About Us // Origin</p><p>Sample Text</p><p>Sample Text</p><p>Sample Text</p></div>
</div>
</div>
<br></br>
And after heading 5:
<ul id="accordion">
<li>
<h2>MENU // SOUPS</h2>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.</p>
</div>
</li>
Picture Reference: http://i.imgur.com/Imc3DPb.png
Thanks in advance!
One of your elements has a default padding or margin. You can inspect your elements with your browsers dev tools to figure out which if not both is causing the issue. Adjust your paddings and margins using padding: x; and margin: x; x being the amount of pixels [ex. 5px] you want.
Problem: http://i.snag.gy/TYvi4.jpg
Fiddle: http://jsfiddle.net/CadDC/7/
As you can see in the problem image above, I would like to position the image alongside the title but keeping the structure of the html for a responsive layout.
<div class="listingWrapper clearfix">
<div class="headlineText">FLOAT: RIGHT</div>
<div class="subText">FLOAT: RIGHT</div>
<div class="logo">FLOAT: LEFT (ALONGSIDE HEADLINE)</div>
<div class="introduction">FLOAT: RIGHT</div>
Look at this fiddle: http://jsfiddle.net/caprella/7kbVX/
I propose to add one more wrapper .heading for .headlineText and .subText. It will give us opportunity to move the whole header. But that .heading steel needs fixed width:(
Check the Js fiddle
http://jsfiddle.net/CadDC/9/
<div class="listingWrapper clearfix">
<div class="logo">
<img class="listingImage" src="http://media-cdn.tripadvisor.com/media/photo-s/02/d0/d7/ed/hotel-du-vin-york.jpg" />
</div>
<div class="headlineText"><h2>Hotel name</h2></div>
<div class="subText">Mars - 0.7 miles from Mars City Centre</div>
<div class="introduction">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nost
</div>
</div>
Cant you just:
.listingImage{
max-width: 190px;
float: left;
}
I think this is your perfect answer http://jsfiddle.net/CadDC/14/ .
If you want it to be responsive you must give width and all in %.