Converting DIV-like page into blog-like layout within CSS? - css

This is my HTML page:
https://jsfiddle.net/62czmtvt/2/ (to actually see the HTML page working)
Code from JSFiddle:
:root {
background-color: #FFFACD;
}
div.infoguide {
width: 240px;
font-family: Arial, sans-serif;
font-size: 13px;
background-color: #F0FFF0;
}
div {
margin: 5;
padding: 0;
border: 0;
outline: 0;
}
A:link {
text-decoration: underline;
color: rgb(204, 51, 51);
}
A:visited {
text-decoration: underline;
color: rgb(204, 51, 51);
}
A:active {
text-decoration: underline;
color: rgb(204, 51, 51);
}
A:hover {
text-decoration: underline;
color: rgb(204, 51, 51);
}
body {
margin-left: 0px;
margin-top: 0px;
}
body,
td,
th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: rgb(46, 46, 46);
line-height: 16px;
}
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
font-weight: bold;
line-height: 20px;
margin-bottom: 0px;
}
h2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
font-weight: bold;
margin-bottom: 0px;
}
h3 {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
font-weight: bold;
margin-bottom: 0px;
}
h3 A:link {
text-decoration: none;
color: rgb(204, 51, 51);
}
h3 A:visited {
text-decoration: none;
color: rgb(204, 51, 51);
}
h3 A:active {
text-decoration: none;
color: rgb(204, 51, 51);
}
h3 A:hover {
text-decoration: underline;
color: rgb(204, 51, 51);
}
ul {
margin-left: 1.5em;
padding-left: 0px;
}
.info_data {
border-color: rgb(137, 137, 137);
border-style: solid;
border-width: 1px;
font-size: 11px;
padding: 4px;
text-align: center;
}
.news_headline {
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
font-weight: bold;
line-height: 22px;
}
.red {
color: rgb(204, 51, 51);
}
.red_padded {
color: rgb(204, 51, 51);
padding: 4px 0px;
}
.redbg {
background-color: rgb(220, 6, 0);
}
<title>First Drive: 2017 Porsche Panamera - Autos.ca</title>
<div class="infoguide">
<H3>It works!</h3>
<p>It works!</p>
</div>
<div class="info_data">
</div>
<div class="infoguide">
<h2 class="red">A headline</h2>
<p>It works!</p>
</div>
It's a sandbox page for a blog-like layout of a magazine site, and I'm trying to achieve this sort of look:
Magazine article
but so far I haven't quite managed to get it to look the way I want to of being a three-column DIV with a header in a pseudo-blog-style layout.
I've been trying the :root element in my CSS file, is this encouraged or discouraged in a HTML5 page?
I would appreciate any advice or help with this!

In order to achieve three columns, you will need to alter your code a bit.
You need a wrapper/container around your three divs you are attempting to separate and give it a 100% width or whatever width you want.
You need to give the three divs a similar second class name and apply a float and a width to those divs. (There are other ways, but this is the clean way).
CSS:
<style>
.page-container {
width: 100%;
}
.infoguide {
float: left;
width: 30%;
}
</style>
HTML:
<title>First Drive: 2017 Porsche Panamera - Autos.ca</title>
<div class="page-container">
<div class="infoguide">
<H3>It works!</h3>
<p>It works!</p>
</div>
<div class="infoguide">
<h1>Test Content</h1>
</div>
<div class="infoguide">
<h2 class="red">A headline</h2>
<p>It works!</p>
</div>
</div>
I would also consider reading into flexbox if you're unfamiliar with it. It's a great way to make responsive webpages with many divs in column format.
https://css-tricks.com/snippets/css/a-guide-to-flexbox/

You're going to have to make a couple of changes:
Wrap the divs that you want to be aside each other in another div (let's call it wrapper).
Float the contents of the wrapper div to the left and give them the desired widths to get the layout.
Make sure to include a clearfix to clear the floats.. or the content that comes after the wrapper div will sit beneath it.
Use media queries to adjust the layout for mobile devices.
This is a very basic example of how to do that. I set a width for container, float the elements, set a width for them and then using media queries, I adjust the layout so that they fill the full width when the viewport is below 500px.
Notice that the main and sidebar don't have any space between them. If you want to separate them with a bit of margin, check this answer of mine.
https://jsfiddle.net/63o6mfy8/2/
Also be sure to clear the floats like I did in the fiddle.
.page-container::after {
content: '';
display: table;
clear: both;
}

You should learn Bootstrap. With Bootstrap you can easily build whatever layout you want. For now you can start with the following snippet. For clear understanding start learning Bootstrap here.
/* These are demo CSS to show the output nicely, do not use these */
.header {
height: 100px;
background: #ffa114;
}
.left-column {
background: #4fff4f;
height: 180px;
}
.right-column {
background: #52a8ff;
}
.footer {
height: 100px;
background: #ffa114;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<div class="container">
<div class="header">
Here is the title
</div>
<div class="container">
<div class="row">
<div class="left-column col-9">
Left Column
</div>
<div class="right-column col-3">
Right Column
</div>
</div>
</div>
<div class="footer">
Bottom Content
</div>
</div>

I'll restate the obvious, and repeated suggestion, to learn and leverage Bootstrap. I'm still learning myself, so maybe the details I've included here will assist you understanding how to leverage the templates that already exist. In this answer I've modified the Jumbotron template, which is included with the Bootstrap download.
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../../../favicon.ico">
<title>Jumbotron Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<main role="main">
<div class="jumbotron"><!-- start jumbotron -->
<div class="container"><!-- start title container -->
<h1>First Drive: 2017 Porsche Panamera</h1>
<h2>Awesome!!!</h2>
</div><!-- end title container -->
</div><!-- end jumbotron -->
<div class="container"><!-- start article container -->
<div class="row"><!-- start container row -->
<div class="col-md-9"><!-- start article column -->
<h2>Intro</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.</p>
<div class="row"><!-- start sub row -->
<div class="col-md-9">
<h3>Article</h3>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
</div>
<div class="col-md-3">
<h3>Mini Side</h3>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
</div>
</div><!-- end sub row -->
</div><!-- end article column -->
<div class="col-md-3"><!-- start side column -->
<h3>Side</h3>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet
risus. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
</div><!-- end side column -->
</div><!-- end container row -->
<hr>
</div><!-- end article container -->
</main>
<footer class="container">
<p>© Company 2017-2018</p>
</footer>
</body>
</html>
One of the beautiful aspects of using Bootstrap is responsive design. You'll need a whole lot more details to replicate the full look of the site example you provided, but I think, other than some of the ad spaces, this should get you started, with the columns necessary to isolate your titles, the article, add images, etc.
You'll also notice that I didn't need to change any of the CSS that's also included with Bootstrap, i just referenced the CDN.
I hope this helps.

Related

Is there a way to reduce the amount of radio buttons shown on smaller screens and then cycle through them?

this is my first time posting, I hope I respected all the guidelines. If not, I'm sorry!
I'm trying to create a responsive website design with the following specs:
1. Large background image, that does not change
2. set of (not yet determined amount) radio(?) buttons below
-> buttons need to be mutually exclusive
3. image overlay with some text, that changes when the respective radio button is pressed
4. when in mobile mode only two buttons should be shown at the same time and two arrows appear to cycle between all possible buttons.
My problem starts at 4):
- I dont have the faintest idea where to start
- I dont know if there is a name for this type of behaviour, that I simply never heard of (which makes googleing a little hard^^)
I thought about Flex-boxes, but all I could manage was to wrap the buttons, but thats not really the same as hiding them.
I also thought about making the buttons simply disappear (display:none), but I'm not so sure on how to do that. (maybe putting additional rules for the bootstrap classes?)
On top of it all, the design needs to be laid out in such a way, that the customer can decide how many buttons there will be, e.g. I have no way of knowing beforehand how many there are, nor can I group them by adding specific classes.
My Question alas is this: can I dynamically embed the radio buttons on slider pages, which i can scroll through, but only if it is in a small screen? (my guess is, this is not a simple css matter)
edit: specified question
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="css/styles.css">
<script src="https://kit.fontawesome.com/82bfdd8cdc.js"></script>
</head>
<body>
<div class="">
<div class="bg-screen">
<img src="img/test.jfif" alt=" " class="bg-screen-img">
<div class="bg-screen-textarea">
</div>
<p class="bg-screen-text dummy"></p>
<div class="radio">
<label>
<input type="radio" name="radio" />
<div class="radio-box box-1">
<i class="fas fa-socks fa-3x"></i>
<span>Choice 1</span>
</div>
<div class="bg-screen-text text-1">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nulla at volutpat diam ut venenatis tellus. Odio ut sem nulla pharetra diam sit
amet. Phasellus egestas tellus rutrum tellus pellentesque eu tincidunt.</div>
</label>
<label>
<input type="radio" name="radio" />
<div class="radio-box box-2">
<i class="fas fa-user-tie fa-3x"></i>
<span>Choice 2</span>
</div>
<div class="bg-screen-text text-2">Sit amet facilisis magna etiam tempor orci eu lobortis. Consectetur lorem donec massa sapien faucibus et molestie ac feugiat.
</div>
</label>
<label>
<input type="radio" name="radio" />
<div class="radio-box box-3">
<i class="fas fa-building fa-3x"></i>
<span>Choice 3</span>
</div>
<p class="bg-screen-text text-3">Risus ultricies tristique nulla aliquet enim tortor at auctor urna.</p>
</label>
<label>
<input type="radio" name="radio" />
<div class="radio-box box-4">
<i class="fas fa-building fa-3x"></i>
<span>Choice 4</span>
</div>
<p class="bg-screen-text text-4">Fringilla ut morbi tincidunt augue. Velit euismod in pellentesque massa placerat duis ultricies lacus. </p>
</label>
<label>
<input type="radio" name="radio" />
<div class="radio-box box-5">
<i class="fas fa-building fa-3x"></i>
<span>Choice 5</span>
</div>
<p class="bg-screen-text text-5">Ut enim blandit volutpat maecenas volutpat blandit aliquam etiam.</p>
</label>
</div>
</div>
</div>
</body>
</html>
input {
display: none;
}
input+div{
background: rgba(76, 175, 80, 0.3);
border: 1px solid grey;
}
input:checked+div {
background-color: green;
}
label {
display: inline-block;
margin: 0 1%;
}
/*removing clickability of text itself inside the labels for the radio-buttons*/
label span {
/* Firefox */
-moz-user-select: none;
/* Internet Explorer */
-ms-user-select: none;
/* KHTML browsers (e.g. Konqueror) */
-khtml-user-select: none;
/* Chrome, Safari, and Opera */
-webkit-user-select: none;
/* Disable Android and iOS callouts*/
-webkit-touch-callout: none;
}
label div i{
margin: 15% auto;
}
input:checked~.bg-screen-text {
display: inline-block;
margin: -25% 10%;
text-align: center;
color: white;
}
.bg-screen{
width: 100%;
text-align: center;
}
.bg-screen-img{
margin: 3% 7%;
height: 25%;
background-color: grey;
}
.bg-screen-text {
display: none;
position: absolute;
text-align: center;
left: 7%;
right:7%;
margin: 0 10%;
}
.radio {
position: relative;
top: -150px;
margin: 3% 7%;
text-align: center;
}
.radio-box {
position: relative;
height: 170px;
width: 170px;
display: inline-block;
text-align: center;
}
.radio-box span {
position: absolute;
transform: translate(0, 90px);
left: 0;
right: 0;
}
Thanks!
I got it working with the help of slick carousel. (https://github.com/kenwheeler/slick/)
This pretty much gave me all the functionality without having to code it myself.

Align button to bottom right of form

I made a simple page using Bootstrap 4 with a contact form and would like the button to be aligned to the bottom right, rather than bottom middle, of it. How can I accomplish this?
Here's the HTML of the form:
<div class="row">
<div class="col center-block">
<div class="contact">
<h2>Contact</h2>
<form action="mailto:test#test.com" method="post" enctype="text/plain">
<div class="form-group">
<input type="text" class="form-control" id="contact-name" placeholder="Name" required>
</div>
<div class="form-group">
<input type="email" class="form-control" id="contact-email" aria-describedby="emailinfo" placeholder="Email" required>
</div>
<div class="form-group">
<input type="text" class="form-control" id="contact-message" placeholder="Your message" required>
</div>
<button type="submit" class="btn btn-dark">Send</button>
</form>
</div>
</div>
</div>
And the CSS applied to buttons and form elements:
.form-control {
width: 50%;
margin: 0 auto;
border-bottom: 1px solid #888;
border-top: 0px;
border-left: 0px;
border-right: 0px;
border-radius: 0;
padding: 10px 0px;
}
input[type=text], input[type=email] {
background-color: WhiteSmoke;
}
button {
margin-top: 1em;
margin-bottom: 2em;
}
Use this code for button:
<div class="bt-btn">
<button type="submit" class="btn btn-dark">Send</button>
</div>
CSS:
.bt-btn {
margin: 0 auto;
text-align: right;
width: 50%;
}
button {
margin-top: 1em;
margin-bottom: 2em;
float: right;
margin-right: 25%;
}
#contact { max-width: 960px; margin: 0 auto; }
form { padding: 75px 25px; }
I would also recommend adding a container around it and give it a max-width of 960px. The whole form area.
You just use d-flex class nothing else and no need to use inline CSS
<div class="d-flex flex-row-reverse">
<button type="submit" class="btn btn-dark" >Send</button>
</div>
That's it.
<div class="form-group col-md-12 text-right mt-2">
<button type="submit" class="btn btn-primary pl-4 pr-4">Submit</button>
</div>
You could do something like.
button {
margin-right: 25%;
float : right;
}
Working example:
body {
font-family: Arial, sans-serif;
text-align: center;
}
h1 {
font-family: "Playfair Display", serif;
padding-top: 0.5em;
}
h2, h5 {
text-transform: uppercase;
/* Padding used instead of margins because whereas margins add space beyond element's box and therefore won't be colored, the inverse is true for padding */
padding: 0.5em 0;
margin: 0;
}
.about p {
padding: 0 4em 2em 4em;
margin: 0;
text-align: left;
}
.nav-link {
text-transform: uppercase;
color: white;
}
.nav-link:hover {
color: white;
}
.hero-image {
background-image: url(https://image.ibb.co/jEN7CS/workspace.jpg);
/* Set a specific height */
height: 100%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
/* Resizes background image to fill entire container */
background-size: cover;
position: relative;
}
.about {
background-color: WhiteSmoke;
}
.portfolio {
background-color: LightGrey;
}
.contact {
background-color: WhiteSmoke;
}
/* Removes white space from sides of each column */
.col {
padding: 0;
}
.footer {
position: bottom;
right: 0;
bottom: 0;
left: 0;
width: 100%;
padding: 0.75rem;
background-color: grey;
}
.footer-tag {
color: white;
text-align: left;
padding: 15px;
}
.fab {
float: right;
padding: 10px;
color: white;
}
.fab:hover {
color: #4d4d4d;
}
.form-control {
width: 50%;
margin: 0 auto;
border-bottom: 1px solid #888;
border-top: 0px;
border-left: 0px;
border-right: 0px;
border-radius: 0;
padding: 10px 0px;
}
input[type=text], input[type=email] {
background-color: WhiteSmoke;
}
button {
margin-top: 1em;
margin-bottom: 2em;
margin-right: 25%;
float : right;
}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<!-- Grey horizontal navbar that becomes vertical on small screens -->
<nav class="navbar sticky-top navbar-expand-sm bg-dark">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#portfolio">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="hero-image">
<div class="hero-text text-white">
<h1>Name</h1>
<h5>Web developer</h5>
<form action="mailto:test#test.com" method="post" enctype="text/plain">
<button class="btn btn-dark">Contact Me</button>
</form>
</div>
</div>
</div>
</div>
<section id="about">
<div class="row">
<div class="col">
<div class="about">
<h2>About</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut hendrerit arcu quis lectus auctor, nec laoreet augue ornare. Proin vehicula id purus ac accumsan. Aliquam eu rutrum orci. Aliquam rhoncus ipsum sed nisi porta mattis. Cras euismod sed justo a vehicula. Maecenas nibh magna, auctor nec erat in, hendrerit blandit turpis. Curabitur laoreet viverra mi at consequat. Donec mollis tortor sem, vel pharetra magna mattis quis. Praesent erat dolor, lacinia at euismod quis, sodales eu orci. Fusce ut nibh dolor. Suspendisse potenti. Proin fermentum eros condimentum hendrerit mattis. Morbi libero nibh, tempus aliquam leo sed, elementum rutrum turpis. Pellentesque et pharetra sapien. Nulla sed quam vel ex dictum egestas in tempus risus. Donec lacus magna, feugiat sed lobortis finibus, bibendum vel magna.</p>
</div>
</div>
</div>
</section>
<section id="portfolio">
<div class="row">
<div class="col">
<div class="portfolio">
<h2>Portfolio</h2>
</div>
</div>
</div>
</section>
<section id="contact">
<div class="row">
<div class="col center-block">
<div class="contact">
<h2>Contact</h2>
<form action="mailto:test#test.com" method="post" enctype="text/plain">
<div class="form-group">
<input type="text" class="form-control" id="contact-name" placeholder="Name" required>
</div>
<div class="form-group">
<input type="email" class="form-control" id="contact-email" aria-describedby="emailinfo" placeholder="Email" required>
</div>
<div class="form-group">
<input type="text" class="form-control" id="contact-message" placeholder="Your message" required>
</div>
<button type="submit" class="btn btn-dark">Send</button>
</form>
</div>
</div>
</div>
</section>
</div> <!-- End of container-fluid -->
<div class="footer">
<i class="fab fa-linkedin fa-2x"></i>
<i class="fab fa-github fa-2x"></i>
<i class="fab fa-codepen fa-2x"></i>
<div class="footer-tag">
<p>Created by Name.</p>
</div>
you need to make the width of your form 50% with margin:auto to keep it centered , and the inputs inside it 100% to fill the width of the form, wrap you button in a form-group and add text-align:right to it, this will keep the responsiveness ,
here's a fiddle : https://jsfiddle.net/takius/j730vdmp/21/
body {
font-family: Arial, sans-serif;
text-align: center;
}
h1 {
font-family: "Playfair Display", serif;
padding-top: 0.5em;
}
h2,
h5 {
text-transform: uppercase;
/* Padding used instead of margins because whereas margins add space beyond element's box and therefore won't be colored, the inverse is true for padding */
padding: 0.5em 0;
margin: 0;
}
.about p {
padding: 0 4em 2em 4em;
margin: 0;
text-align: left;
}
.nav-link {
text-transform: uppercase;
color: white;
}
.nav-link:hover {
color: white;
}
.hero-image {
background-image: url(https://image.ibb.co/jEN7CS/workspace.jpg);
/* Set a specific height */
height: 100%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
/* Resizes background image to fill entire container */
background-size: cover;
position: relative;
}
.about {
background-color: WhiteSmoke;
}
.portfolio {
background-color: LightGrey;
}
.contact {
background-color: WhiteSmoke;
}
/* Removes white space from sides of each column */
.col {
padding: 0;
}
.footer {
position: bottom;
right: 0;
bottom: 0;
left: 0;
width: 100%;
padding: 0.75rem;
background-color: grey;
}
.footer-tag {
color: white;
text-align: left;
padding: 15px;
}
.fab {
float: right;
padding: 10px;
color: white;
}
.fab:hover {
color: #4d4d4d;
}
.form-control {
width: 100%;
margin: 0 auto;
border-bottom: 1px solid #888;
border-top: 0px;
border-left: 0px;
border-right: 0px;
border-radius: 0;
padding: 10px 0px;
}
input[type=text],
input[type=email] {
background-color: WhiteSmoke;
}
button {
margin-top: 1em;
margin-bottom: 2em;
}
form {
width: 50%;
margin: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<!-- Grey horizontal navbar that becomes vertical on small screens -->
<nav class="navbar sticky-top navbar-expand-sm bg-dark">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#portfolio">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="hero-image">
<div class="hero-text text-white">
<h1>Name</h1>
<h5>Web developer</h5>
<form action="mailto:test#test.com" method="post" enctype="text/plain">
<button class="btn btn-dark">Contact Me</button>
</form>
</div>
</div>
</div>
</div>
<section id="about">
<div class="row">
<div class="col">
<div class="about">
<h2>About</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut hendrerit arcu quis lectus auctor, nec laoreet augue ornare. Proin vehicula id purus ac accumsan. Aliquam eu rutrum orci. Aliquam rhoncus ipsum sed nisi porta mattis. Cras euismod sed
justo a vehicula. Maecenas nibh magna, auctor nec erat in, hendrerit blandit turpis. Curabitur laoreet viverra mi at consequat. Donec mollis tortor sem, vel pharetra magna mattis quis. Praesent erat dolor, lacinia at euismod quis, sodales
eu orci. Fusce ut nibh dolor. Suspendisse potenti. Proin fermentum eros condimentum hendrerit mattis. Morbi libero nibh, tempus aliquam leo sed, elementum rutrum turpis. Pellentesque et pharetra sapien. Nulla sed quam vel ex dictum egestas
in tempus risus. Donec lacus magna, feugiat sed lobortis finibus, bibendum vel magna.</p>
</div>
</div>
</div>
</section>
<section id="portfolio">
<div class="row">
<div class="col">
<div class="portfolio">
<h2>Portfolio</h2>
</div>
</div>
</div>
</section>
<section id="contact">
<div class="row">
<div class="col center-block">
<div class="contact">
<h2>Contact</h2>
<form action="mailto:test#test.com" method="post" enctype="text/plain">
<div class="form-group">
<input type="text" class="form-control" id="contact-name" placeholder="Name" required>
</div>
<div class="form-group">
<input type="email" class="form-control" id="contact-email" aria-describedby="emailinfo" placeholder="Email" required>
</div>
<div class="form-group">
<input type="text" class="form-control" id="contact-message" placeholder="Your message" required>
</div>
<div class="form-group" style="text-align:right;">
<button type="submit" class="btn btn-dark">Send</button>
</div>
</form>
</div>
</div>
</div>
</section>
</div>
<!-- End of container-fluid -->
<div class="footer">
<i class="fab fa-linkedin fa-2x"></i>
<i class="fab fa-github fa-2x"></i>
<i class="fab fa-codepen fa-2x"></i>
<div class="footer-tag">
<p>Created by Name.</p>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

CSS print page-break-after not working with CSS Grid layout

I'm using the new CSS3 layout technique defined by gridbyexample.com.
It's works very well except when I try to print the layout. Chrome and Firefox seem to be ignoring any page breaks and the landscape view mode I have defined in the CSS. I have a code pen for my project but it seems to change how it looks in print preview mode so it's only good for looking at HTML and CSS but not how the print will look.
https://codepen.io/JeffreySpring/pen/rzjeKm
I have created a .zip file with all the files and images that can be downloaded from https://drive.google.com/open?id=0B0LdH-fKpAKeY0NRa290M25uTGc
Here is the HTML
<!DOCTYPE html>
<html>
<head>
<title>Steam Controller Bindings Template</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body cz-shortcut-listen="true" style="">
<ul class="wrapper">
<li class="device">
<div id="steamDeviceContainer">
<div><h1>Couch Gamer's Witcher 3 Bindings</h1></div>
<img src="img/steam_controller.png" alt="Steam Controller">
</div>
<div class="mappingGyroShift1">
<h3 class="mappingHeader gyroShift1">Gyro<span class="boundTo gyroShift1">(Mouse Joystick)</span></h3>
<div class="actionBind gyroShift1">Precision Crossbow/Bomb Aim</div>
</div>
</li>
<li>
<div class="mapping">
<h3 class="mappingHeader">Left Trigger</h3>
<div class="actionBind">Use Witcher Senses</div>
<div class="actionBind">Block or Counterattack</div>
</div>
<div class="mapping">
<h3 class="mappingHeader">Left Bumper</h3>
<div class="actionBind">Quick choice menu</div>
</div>
<div class="mapping">
<h3 class="mappingHeader">Select Button</h3>
<div class="actionBind">Pause Game/Game Options</div>
<div class="actionBind">HOLD: Inventory Screen</div>
</div>
<div class="mapping">
<h3 class="mappingHeader">Left Grip</h3>
<div class="actionBind">Use Item</div>
<div class="actionBind gyroShift1">HOLD: (GYRO ON) Aim Crossbow/Bomb</div>
</div>
</li>
<li>
<div class="mapping">
<h3 class="mappingHeader">Right Trigger</h3>
<div class="actionBind">Use Sign</div>
</div>
<div class="mapping">
<h3 class="mappingHeader">Right Bumper</h3>
<div class="actionBind">Quick Save</div>
</div>
<div class="mapping">
<h3 class="mappingHeader">Start Button</h3>
<div class="actionBind">In Game Menu</div>
<div class="actionBind">HOLD: Map</div>
</div>
<div class="mapping">
<h3 class="mappingHeader">Right Grip</h3>
<div class="actionBind modeShift1">Mode Shift Left TouchPad</div>
<div class="actionBind modeShift1">Mode Shift A Button</div>
</div>
</li>
<li class="wide">
<div class="mapping pageBreakAfter">
<h3 class="mappingHeader">Left Joystick<span class="boundTo">(Joystick Move)</span></h3>
<div class="actionBind">ROTATE: Move Character</div>
<div class="actionBind">DOUBLE PRESS: Call your mount</div>
</div>
</li>
<li class="wide">
<div class="mapping pageBreakAfter">
<h3 class="mappingHeader">Face Buttons<span class="boundTo">(Button Pad)</span></h3>
<div class="actionBind aBtn">A BUTTON: Interact/Roll</div>
<div class="actionBind aBtn">A BUTTON HOLD: Run/Quick Swim/Gallop/Accelerate Boat</div>
<div class="actionBind aBtn">A BUTTON QUICK DOUBLE PRESS THEN HOLD: Full Gallop</div>
<div class="actionBind bBtn">B BUTTON: Jump/Dodge/Let helm go</div>
<div class="actionBind bBtn">B BUTTON HOLD: Resurfacing</div>
<div class="actionBind yBtn">Y BUTTON: Strong attack</div>
<div class="actionBind xBtn">X BUTTON: Fast Attack</div>
<div class="actionBind xBtn">X BUTTON HOLD: Submerging/Stop the Boat</div>
<div class="actionBind modeShift1">A BUTTON: Autoloot</div>
</div>
</li>
<li class="wide">
<div class="mapping">
<h3 class="mappingHeader">Left TouchPad<span class="boundTo">(4 way D-Pad)</span></h3>
<div class="actionBind">D-PAD UP: Consumable 1/3</div>
<div class="actionBind">D-PAD UP HOLD: Switch to Consumable 1/3</div>
<div class="actionBind">D-PAD DOWN: Consumable 2/4</div>
<div class="actionBind">D-PAD UP HOLD: Switch to Consumable 2/4</div>
<div class="actionBind">D-PAD LEFT: Drawing or hiding steel sword</div>
<div class="actionBind">D-PAD LEFT: Drawing or hiding silver sword</div>
<div class="actionBind modeShift1">MODE SHIFT RIGHT GRIP: Radial Menu 1</div>
</div>
</li>
<li class="wide">
<div class="mapping">
<h3 class="mappingHeader">Right TouchPad<span class="boundTo">(4 way D-Pad)</span></h3>
<div class="actionBind">D-PAD UP: Consumable 1/3</div>
<div class="actionBind">D-PAD UP HOLD: Switch to Consumable 1/3</div>
<div class="actionBind">D-PAD DOWN: Consumable 2/4</div>
<div class="actionBind">D-PAD UP HOLD: Switch to Consumable 2/4</div>
<div class="actionBind">D-PAD LEFT: Drawing or hiding steel sword</div>
<div class="actionBind">D-PAD LEFT: Drawing or hiding silver sword</div>
</div>
</li>
<li class="full">
<div class="mappingModeShift1">
<h3 class="mappingHeader modeShift1">Radial Menu 1<span
class="boundTo modeShift1">(6 button touch menu)</span></h3>
<div class="actionBind modeShift1">BUTTON 1: Aard</div>
<div class="actionBind modeShift1">BUTTON 2: Yrden</div>
<div class="actionBind modeShift1">BUTTON 3: Igni</div>
<div class="actionBind modeShift1">BUTTON 4: Quen</div>
<div class="actionBind modeShift1">BUTTON 5: Axii</div>
<div class="actionBind modeShift1">BUTTON 6: Swap Crossbow/Bomb</div>
</div>
</li>
<li class="full">
<div class="mapping">
<h3 class="mappingHeader">Details</h3>
<div class="notes">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis efficitur arcu ut sapien ullamcorper,
vel ornare tellus venenatis. Pellentesque non sapien magna. Suspendisse potenti. Duis et turpis
sapien.
Donec turpis odio, posuere dignissim ornare semper, commodo a nunc. Nunc lacinia felis id elementum
vehicula.
Curabitur vel risus luctus, ornare nulla ac, tincidunt tellus. Nam tortor lorem, aliquet ut
efficitur vel,
</p>
<p>
ullamcorper vel metus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus.
Nam v
itae odio arcu. Phasellus fermentum nisi ipsum, a viverra urna placerat dignissim. Ut tempus finibus
mauris
faucibus consequat. Proin eu risus interdum, malesuada lectus id, egestas tortor. In imperdiet eget
augue et semper.
Sed risus justo, pulvinar id velit et, ullamcorper posuere ex. Nulla vel laoreet purus. Vivamus sed
venenatis erat,
in aliquam lectus. Mauris et lectus id eros feugiat viverra eu eu massa.
</p>
<p>
Nam egestas malesuada ligula quis cursus. Duis quis lorem in nunc maximus malesuada. Cras ante enim,
tincidunt ac
risus vel, elementum tincidunt erat. Ut auctor dolor a metus ornare auctor. Pellentesque at tellus
mi. Morbi e
fficitur metus vel enim ullamcorper, quis sagittis eros condimentum. Phasellus laoreet consectetur
lectus et dapibus.
Morbi tincidunt id mi nec ullamcorper. Integer dictum, justo vitae ullamcorper tristique, lorem nunc
rutrum augue, ut
pellentesque diam purus at ex. Proin sollicitudin iaculis eros.
</p>
</div>
</div>
</li>
<li class="full noPrint">
<div class="mapping">
<h3 class="mappingHeader">Screenshots</h3>
<div class="notes">
<div>
<img src="img/customRadialMenu.png" alt="Custom Menu Screenshot">
</div>
</div>
</div>
</li>
<li class="full noPrint">
<div id="videoWrapper">
<div class="video-container">
<iframe width="560" height="315" src="https://www.youtube.com/embed/4lcm4bdtkZs" frameborder="0"
allowfullscreen></iframe>
</div>
</div>
</li>
</ul>
</body>
</html>
Here is the CSS
/*noinspection CssUnknownTarget*/
#import url('https://fonts.googleapis.com/css?family=Oswald');
html {
box-sizing: border-box;
font-family: 'Oswald', sans-serif;
}
*, *:before, *:after {
box-sizing: inherit;
background-color: #00335B;
color: #F9F3F4;
}
img {
max-width: 100%;
}
.wrapper {
list-style: none;
margin: 0 auto 0 auto;
padding: 0;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto;
grid-auto-flow: dense;
}
#media print {
.noPrint {
display: none !important;
}
#page {
size: landscape; /* auto is the initial value */
/* this affects the margin in the printer settings */
margin: 25px 25px 25px 25px;
}
div.pageBreakAfter {
page-break-after: always;
page-break-inside: avoid;
}
div.pageBreakBefore {
page-break-before: always;
page-break-inside: avoid;
}
}
#media (min-width: 460px) {
.wrapper {
grid-template-columns: 1fr 1fr;
}
.device {
grid-column: 1 / 3;
}
.full {
grid-column: auto / span 2;
}
}
#media (min-width: 660px) {
.wrapper {
grid-template-columns: 1fr 1fr 1fr 1fr;
}
.device {
grid-column: 2 / 4;
grid-row: 1 / 3;
}
.wide {
grid-column: auto / span 2;
}
.full {
grid-column: auto / span 4;
}
}
.wrapper li {
margin: 10px;
padding: 10px;
}
h1 {
font-family: 'Oswald', sans-serif;
color: #F9F3F4;
text-shadow: 0 0 300px #000;
font-size: 150%;
text-align: center;
}
.mapping {
border: solid #F9F3F4 3px;
border-radius: 9px;
font-family: 'Oswald', sans-serif;
color: #F9F3F4;
margin: 20px;
}
.mappingModeShift1 {
border: solid #FF8C00 3px;
border-radius: 9px;
font-family: 'Oswald', sans-serif;
color: #FF8C00;
margin: 20px;
}
.mappingGyroShift1 {
border: solid #00FFFF 3px;
border-radius: 9px;
font-family: 'Oswald', sans-serif;
color: #00FFFF;
margin: 20px;
}
.mappingHeader {
padding-left: 3px;
padding-right: 3px;
font-family: 'Oswald', sans-serif;
font-style: normal;
position: relative;
left: 30px;
top: -10px;
text-transform: uppercase;
display: inline;
}
#steamDeviceContainer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#videoWrapper {
margin-left: 15px;
margin-right: 15px;
}
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-container iframe, .video-container object, .video-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.actionBind {
margin-left: 30px;
margin-right: 10px;
padding-bottom: 10px;
}
.notes {
margin-left: 30px;
margin-right: 30px;
margin-bottom: 30px;
padding-bottom: 10px;
}
.boundTo {
font-size: xx-small;
vertical-align: super;
padding: 2px;
}
.modeShift1 {
color: #FF8C00 !important;
}
.gyroShift1 {
color: #00FFFF !important;
}
.yBtn {
color: #F4D00F;
}
.xBtn {
color: #0084C4;
}
.aBtn {
color: #34A853;
}
.bBtn {
color: #fc0602;
}
As you have found page pages do not work inside of grid layout block. I tried everything I could think of, but just doesn't work.
The solution to my report was to do the page-break-before outside the grid layout block.
It makes it a little trick, but it can be done. You just have to make sure your page-break is outside any display: grid class.

Align image next to a paragraph

Not just a simple image next to a paragraph< but with some spaces like this
(source: gyazo.com)
So far of what I've done :
<div class="span6">
<span class="head">Header</span>
<img style="vertical-align:middle float: left;" src="img/pickaxe.png"/>
<span class="paragraph">
This is Photoshop's version of Lorem Ipsum.
Proin gravida nibh vel velit auctor aliquet.
Aenean sollicitudin, lorem quis bibendum auc
tor, nisi elit consequat ipsum, nec sagittis sem nibh i
</span>
</div>
.span8 {
width: 620px;
}
.head {
font-weight: bold;
font-size: 26px;
float: left;
}
.paragraph {
font-size: 14px;
width: 300px;
}
And it looks like this
(source: gyazo.com)
Ignore the line, it's a cropper image off the web.
What am I doing wrong? how can I fix this.
Thanks!
Here is a jsfiddle for you: http://jsfiddle.net/Xxw85/
The code should look more like this:
<div class="span6">
<p>Header</p>
<div class="head">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRgMvCRHrTA30jksWsHfDZ4GwWfjJhM8Ck2RAtA_OLeOpnGRTrEXw"/>
</div>
<div class="paragraph">
This is Photoshop's version of Lorem Ipsum. Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auc
tor, nisi elit consequat ipsum, nec sagittis sem nibh i
</div>
<div style="clear:both"></div>
</div>
and css:
.span6 {
width: 620px;
background-color:#efefef;
}
.head {
font-weight: bold;
font-size: 26px;
float: left;
color:red;
}
.paragraph {
font-size: 14px;
width: 300px;
float:left;
}
Good luck.
Consider this fiddle. I have used div element instead of the span element inside the parent div.
<div>
<div class="head">Header</div>
<img style="vertical-align:middle float: left;" src="img/pickaxe.png"/>
</div>
And float the content to the right by adding this.
.paragraph {
float:right;}
http://jsfiddle.net/AaXTm/8/
The width of the element was less than the parent element and since you didn't use any floats or clear, the elements were visible inline.

how to enforce hover state div is shown above other elements and outside of container?

i've been going over this one for about two days.
example
it's a fairly complicated design, so to reduce code pasted here i've recreated the main structure on this jsfiddle and included the simplified code at the end of this post:
http://jsfiddle.net/rwone/zwxpG/10/
scenario
i have a container with numerous <li>'s containing a div (containing dynamic content from a database) that initially has the property display: none.
on hovering over an image in these <li>'s however, i wish to show the div.
it is working, however the div appears to be beneath other elements in the container which has a fixed height and overflow-y: auto.
what i've tried
i have tried combinations of z-index's and absolute and relative positioning, but i haven't been able to find a solution yet.
i've isolated two causes in the code below and the jsfiddle (shown as /* comments */) but these do not work on the live test site.
question
my question is therefore, is there another way to enforce that the hover state div is shown on top of and outside of the container that is enclosing it?
it is not an ideal solution that i can fix these issues in the jsfiddle but not the live site, but i just thought i'd ask if there was another way to approach this altogether?
thank you.
html
<div id="wrapper">
<div id ="hbar_one"></div>
<div id="hbar_two"></div>
<div id="container_a">
<div id="container_b">
<ul>
<li>
hover me #1
<div id="container_c">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In fringilla porttitor ante ut varius. Fusce volutpat velit ut orci porttitor cursus. Donec est eros, tempor ac elementum et, volutpat sit amet lorem. Mauris iaculis eros nec sapien hendrerit at sodales nibh iaculis. Morbi imperdiet porta est vitae suscipit. Curabitur sit amet diam in nulla consectetur placerat. Etiam in sapien ac mi scelerisque congue eu id lectus. Proin fermentum auctor turpis vel adipiscing. Maecenas at convallis sapien.
</div>
</li>
<li>
hover me #2
<div id="container_c">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In fringilla porttitor ante ut varius. Fusce volutpat velit ut orci porttitor cursus. Donec est eros, tempor ac elementum et, volutpat sit amet lorem. Mauris iaculis eros nec sapien hendrerit at sodales nibh iaculis. Morbi imperdiet porta est vitae suscipit. Curabitur sit amet diam in nulla consectetur placerat. Etiam in sapien ac mi scelerisque congue eu id lectus. Proin fermentum auctor turpis vel adipiscing. Maecenas at convallis sapien.
</div>
</li>
</ul>
</div>
</div>
<div id="hbar_three"></div>
<div id="hbar_four"></div>
</div>
css
#wrapper {
width: 300px;
}
#hbar_one {
background: #cc0000;
height: 50px;
}
#hbar_two {
background: #ffcc00;
height: 50px;
}
#container_b {
height: 50px;
/* cause one - on its own, this causes the undesired 'underneath' effect */
overflow-y: auto;
}
ul li {
display: inline;
/* cause two - on its own, this causes the undesired 'underneath' effect */
position: relative;
}
#container_c {
display: none;
}
ul li:hover #container_c {
background: #00AFF0;
display: block;
width: 200px;
height: 200px;
position:absolute;
top: -20px;
left: 50px;
z-index: 999;
overflow: hidden;
}
#hbar_three {
background: #cccccc;
height: 50px;
}
#hbar_four {
background: #000000;
height: 50px;
}
update
in response to answer below, here is further information on the actual content that is being displayed upon hover (everything within the #container_c div). each <li> has its own unique content:
​<li class=".class1 .class2">
<img src="http://path/to/image.jpg">
<div id="container_c">
<h4>title</h4>
<div id="container_c_left">
<span id="cl1">text</span>
<span id="cl2">text</span>
<span id="cl3">text</span>
</div>
<div id="container_c_right">
<span id="cr1">text</span>
<span id="cr2">text</span>
</div>
<span id="cc1">text</span>
<span id="cc2"><a class= "linkclass" href="http://path/to/link.html">link</a></span>
</div>
</li>
You only want to display one of these hover elements at a time?
Put a single DIV outside of the main body and make it hidden.
Then use javascript to adjust its position and content every time you hover over an LI.
No need to give every LI its own DIV.
Store the contents inside a data attribute
<li id=something data-some-content="Hello joe">
Then you can retrieve it with jQuery like so
$("#something").data('some-content')
Your CSS styles are correct but in your HTML you have two <div> elements with the id='container_c' and that's invalid, IDs are unique and you can't give same id to two or more elements. If you two ore more elements to be given same style then try class='container_c' and in the CSS change the #container_c to .container_c
Check this fiddle for the fixed version
http://jsfiddle.net/DeepakKamat/zwxpG/13/
the solution was a mixture of #NoPyGod's jquery suggestion and to have a better understanding of how absolute and relative positioning work.
basically, when absolute and relative positioning are applied to a div, this position is relative to the position of the last element that had absolute or relative positioning defined and is a 'container' of the div you are working with.
to escape from the 'container' that had overflow: auto and a fixed height and width, i had to remove erroneous positioning back till a parent div that was not constrained by overflow and height and width restraints that were impacting on the hover state div.
a working jsfiddle is here:
http://jsfiddle.net/rwone/eeaAr/
i also implemented #Deepak Kamat's suggestion to only have one id per page and change the rest of the div's to be identified by classes.
i subsequently read the article below that made more sense to me this time and after working in this context:
http://css-tricks.com/the-difference-between-id-and-class/
thank you to all for your assistance!
html
<div id="wrapper">
<div id ="hbar_one"></div>
<div id="hbar_two"></div>
<div id="container_a">
<div id="container_b">
<div class="class1 class2 magic" data-unique-content=".hidden_db_data_div">
<img src="http://lorempixel.com/g/50/50/">
<div class="hidden_db_data_div">
some amazing html
</div>
</div>
<div class="class1 class2 magic" data-unique-content=".hidden_db_data_div">
<img src="http://lorempixel.com/g/50/50/">
<div class="hidden_db_data_div">
more amazing html
</div>
</div>
<div class="class1 class2 magic" data-unique-content=".hidden_db_data_div">
<img src="http://lorempixel.com/g/50/50/">
<div class="hidden_db_data_div">
even more amazing html
</div>
</div>
</div>
</div>
<div id="hbar_three"></div>
<div id="hbar_four"></div>
</div>
css
#wrapper {
width: 300px;
}
#hbar_one {
background: #cc0000;
height: 50px;
}
#hbar_two {
background: #ffcc00;
height: 50px;
}
#container_b {
height: 100px;
overflow-y: auto;
}
.hidden_db_data_div {
display: none;
background: #00AFF0;
width: 120px;
height: 150px;
color: red;
position:absolute;
overflow: hidden;
z-index: 999;
}
img {
width: 50px;
height: 50px;
}
.magic {
display: inline;
}
#container_a { position:relative; }
#hbar_three {
background: #cccccc;
height: 50px;
}
#hbar_four {
background: #000000;
height: 50px;
}
script
$(".magic").hover(
function () {
$(this)
.find('.hidden_db_data_div')
.css({'left':$(this).position().left+20 + "px", 'top':'-20px'})
.fadeIn(200);
},
function() {
$(this)
.find('.hidden_db_data_div')
.fadeOut(100);
}
);

Resources