I am generating a coupon type display by html and css without creating and storing the real image on server to save space.
Plan is to display it and get it printed out when user wants to print. I have managed to create the layout by HTML and css and it displays as follows,
But when the Print Now button is clicked there are so much blank space created towards the left side, please see the image below,
I can not figure out what might be the issue here, I am attaching the HTML and CSS below.
HTML
<div class="print-coupon-text">
<div class="pct-heading">
<img src="***image-source***" alt="Created by JAiCOUPONS" />
</div>
<div class="pct-col pct-col-1">
<div class="pct-store-logo">
<img src="***image-source***" alt="Coupon Store" />
</div>
<div class="pct-store-desc">
<span>http://abcdexample.com</span>
<span>#2333, 1st Comfort Road</span>
<span>Redint TF 78999</span>
<span>210 Price Fork Road</span>
<span>Redint TF 78999</span>
<span>(333) 323-4444</span>
</div>
</div>
<div class="pct-col pct-col-2">
<span class="pct-offer-1">$50</span>
<span class="pct-offer-2">Off</span>
<span class="pct-offer-3"> Free Icecream </span>
</div>
<div class="pct-col pct-col-3">
<span class="pct-title">Buy 1 Dinner</span>
<span class="pct-title pct-title-end">And get the 2nd one Free</span>
<span class="pct-desc">Dine In, Carryout Only</span>
<span class="pct-desc">Excludes buffet with this coupon</span>
<span class="pct-desc">Not Valid with other Offers</span>
<span class="pct-desc">Expires : 15th Jan</span>
</div>
<div class="pct-footer">
<span class="pct-footer-1">Contact JAiCOUPONS # (972) 301-7898</span>
<span class="pct-footer-2">Coupon ID **** | ©JAiCOUPONS.com</span>
</div>
</div>
CSS
.print-coupon-text {
position: relative;
width: 100%;
float: left;
margin-bottom: 10px;
padding: 10px;
border: 1px dashed #000;
border-radius: 10px;
font-size: 10px;
text-align: left;
}
.pct-col {
width: 30%;
float: left;
margin: 0 8px;
}
.pct-store-desc span, .pct-footer span, .pct-desc {
display: block;
}
.pct-col.pct-col-2 {
padding-left: 5px;
padding-top: 85px;
}
.pct-col.pct-col-3 {
padding-top: 40px;
}
.pct-offer-1 {
font-size: 60px;
font-weight: bold;
}
.pct-offer-2 {
font-weight: bold;
}
.pct-offer-3 {
display: block;
}
.pct-title {
display: block;
font-size: 13px;
}
.pct-title-end {
border-bottom: 1px dotted;
padding-bottom: 5px;
}
.pct-store-logo img {
width: 150px;
height: 85px;
}
.pct-heading {
position: absolute;
top: 0px;
left: 28%;
}
.pct-heading img {
width: 90%;
}
.pct-footer-1 {
position: absolute;
bottom: 16px;
right: 6px;
}
.pct-footer-2 {
position: absolute;
bottom: 0px;
right: 6px;
}
#media print {
body * {
visibility: hidden;
}
.print-coupon-text, .print-coupon-text * {
visibility: visible;
}
.print-coupon-text {
position: absolute;
left: 0;
top: 0;
}
}
Any help is appreciated.
UPDATE
Initial display is coming on the pop up.
I think you should give fixed width to your div.print-coupon-text
.print-coupon-text{
width: 700px; // or greater/less
}
Hi try displaying the coupon in its own page, you won't have this issue in that case. check screenshots below.
BTW, i was not able to replicate your issue, working fine for me with your code.
EDIT :: Tried using Bootstrap Popup as well, working fine.
.print-coupon-text {
position: relative;
width: 100%;
float: left;
margin-bottom: 10px;
padding: 10px;
border: 1px dashed #000;
border-radius: 10px;
font-size: 10px;
text-align: left;
}
.pct-col {
width: 30%;
float: left;
margin: 0 8px;
}
.pct-store-desc span,
.pct-footer span,
.pct-desc {
display: block;
}
.pct-col.pct-col-2 {
padding-left: 5px;
padding-top: 85px;
}
.pct-col.pct-col-3 {
padding-top: 40px;
}
.pct-offer-1 {
font-size: 60px;
font-weight: bold;
}
.pct-offer-2 {
font-weight: bold;
}
.pct-offer-3 {
display: block;
}
.pct-title {
display: block;
font-size: 13px;
}
.pct-title-end {
border-bottom: 1px dotted;
padding-bottom: 5px;
}
.pct-store-logo img {
width: 150px;
height: 85px;
}
.pct-heading {
position: absolute;
top: 0px;
left: 28%;
}
.pct-heading img {
width: 90%;
}
.pct-footer-1 {
position: absolute;
bottom: 16px;
right: 6px;
}
.pct-footer-2 {
position: absolute;
bottom: 0px;
right: 6px;
}
#media print {
body * {
visibility: hidden;
}
.print-coupon-text,
.print-coupon-text * {
visibility: visible;
}
.print-coupon-text {
position: absolute;
left: 0;
top: 0;
}
}
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Popup</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body">
<div class="print-coupon-text">
<div class="pct-heading">
<img src="***image-source***" alt="Created by JAiCOUPONS" />
</div>
<div class="pct-col pct-col-1">
<div class="pct-store-logo">
<img src="***image-source***" alt="Coupon Store" />
</div>
<div class="pct-store-desc">
<span>http://abcdexample.com</span>
<span>#2333, 1st Comfort Road</span>
<span>Redint TF 78999</span>
<span>210 Price Fork Road</span>
<span>Redint TF 78999</span>
<span>(333) 323-4444</span>
</div>
</div>
<div class="pct-col pct-col-2">
<span class="pct-offer-1">$50</span>
<span class="pct-offer-2">Off</span>
<span class="pct-offer-3"> Free Icecream </span>
</div>
<div class="pct-col pct-col-3">
<span class="pct-title">Buy 1 Dinner</span>
<span class="pct-title pct-title-end">And get the 2nd one Free</span>
<span class="pct-desc">Dine In, Carryout Only</span>
<span class="pct-desc">Excludes buffet with this coupon</span>
<span class="pct-desc">Not Valid with other Offers</span>
<span class="pct-desc">Expires : 15th Jan</span>
</div>
<div class="pct-footer">
<span class="pct-footer-1">Contact JAiCOUPONS # (972) 301-7898</span>
<span class="pct-footer-2">Coupon ID **** | ©JAiCOUPONS.com</span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Related
I am able to make my text in the center but using px values. When I try using percentage it is not working. I tried display:table; and display:table-cell and also display:flex;
justify-content: center; //horizontal centering
align-items:center; but it did not work.
My parent div has height: 7.7% .
Note: I have updated my full header code
Below is JSFIDDLE link:
https://jsfiddle.net/Anthony_Chien/f7n77068/#&togetherjs=gR8VEaLgqR
HTML:
<div class="vav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
<span>DS</span>
</div>
<div class="navheadersec2">
<div class="navheadermargin">
<div class="btn-group">
<button class="btn btn-default btn-md dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="headerspanbox"> <div class="headerdivbox"></div> </span>Default <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</div>
<!--<div class="header-icons">
<span class="icons-group"><img src="assets/images/icons/undo.png" /></span>
<span class="icons-label">Undo</span>
</div>-->
<span class="btn-group icons-grp"><img src="assets/images/icons/undo.png" /><br>Undo</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/redo.png" /><br>Redo</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/zoom-in.png" /><br></span>
<span class="btn-group icons-grp"><img src="assets/images/icons/zoom-out.png" /><br></span>
<span class="btn-group icons-grp"><img src="assets/images/icons/group.png" /><br>Group</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/pattern.png" /><br>Pattern</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/lock.png" /><br>Lock</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/select.png" /><br>Select</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/resize.png" /><br>Scale</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/rotate.png" /><br>Rotate</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/rotate.png" /><br>Forward</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/backward.png" /><br>Backward</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/panel.png" /><br>Panel</span>
</div>
</div>
<div class="navheadersec3">
<div class="navheadermargin">
<div class="headersec3para">
<p class="headerpara">Code</p>
<p class="headerpara">Some text</p>
</div>
<p class="header-price">2,550</p>
<span class="btn-group icons-grp info-icon"><img src="assets/images/icons/info.png" /></span>
<p class="header-price add-to-cart">ADD</p>
</div>
</div>
</nav>
</div>
CSS:
.vav-main{
width: 100%;
height: 100%;
}
.navheader{
width: 100%;
height: 7.7%;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
width: 5%;
height: 100%;
background-color: #ffffff;
position:relative; /* Add this property */
transform:translate(-50% -50%); /* Add this property */
top:50%; /* Add this property */
left:50%; /* Add this property */
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
}
.navheadersec2 {
width: 64.76%;
display: inline-block;
border-right: solid 1px #b8b8b8;
height: 100%;
}
.navheadersec3{
width: 30.214%;
display: inline-block;
margin-left: -4px;
}
.navheadermargin .headersec3para{
width: 30.53%;
height: 100%;
float: left;
margin-left: 6.10%;
}
.headersec3para .headerpara:first-child{
font-size: 12px;
margin: 0px !IMPORTANT;
font-weight: bold;
}
.headersec3para .headerpara{
font-size: 10px;
margin: 0px !IMPORTANT;
}
.header-price{
margin: 0px;
height: 100%;
width: 16.03%;
float: left;
text-align: center;
line-height: 34px;
font-weight: bold;
font-size: 18px;
font-family: SourceSansPro;
}
.info-icon{
margin: auto;
text-align: center;
line-height: 34px;
}
.info-icon > img{
width: 20px;
height: 20px;
}
.add-to-cart{
width: 30.534%;
font-size: 15px;
color: #009cff;
}
.navheadermargin{
margin-top: 10px;
height: 34px;
margin-bottom: 10px;
}
.navheadermargin .btn-group{
margin-left: 1.3%;
height: 100%;
width: 13.510%;
float: left;
}
.navheadermargin .header-icons{
float: left;
width: 24px;
height: 100%;
}
.header-icons .icons-group{
height: 21px;
}
.header-icons .icons-group img{
height: 20px;
width: 20px;
}
.header-icons .icons-label{
height: 15px;
font-family: SourceSansPro;
font-size: 10px;
}
.navheadermargin .btn-group button{
height: 100%;
width: 100%;
}
.headerspanbox{
display: inline-block;
}
.headerspanbox .headerdivbox{
background-color: #1fb6ff;
margin-right: 10px;
height: 14px;
width: 18px;
}
Screenshot Image:
.vav-main{
width: 100%;
height: 100%;
}
.navheader{
width: 100%;
height: 7.7%;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
width: 5%;
height: 100%;
background-color: #ffffff;
position:relative; /* Add this property */
transform:translate(-50% -50%); /* Add this property */
top:50%; /* Add this property */
left:50%; /* Add this property */
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
}
.vav-main> .navbar {
margin-bottom: 0px;
min-height:initial;
}
<div class="vav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
<span>DS....</span>
</div>
</nav>
</div>
You can use flex for achieve the same.
update fiddle below
working fiddle
.vav-main{
width: 100%;
height: 100%;
}
.navheader{
width: 100%;
height: 7.7%;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
height: 100%;
width:100%;
background-color: #ffffff;
display:flex;
justify-content:center;
align-items:center;
flex-flow:column nowrap;
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
}
.navlogo span a {
align-self:center;
}
.vav-main> .navbar {
margin-bottom: 0px;
min-height:initial;
}
<div class="vav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
<span>DS....</span>
</div>
</nav>
</div>
You can use display: table; on your container, and display: table-cell; on your children, to center vertically and horizontally your navigation elements. Ypu can then set container and elements width based on the layout you need.
Possible example :
.vav-main{
position: relative;
width: 100%;
height: 100%;
}
.navbar{
display: table;
width: 100%;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
height: 100;
background-color: #ffffff;
width: 5%;
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
}
.navbar-header {
display: table-cell;
padding: 3.5%;
vertical-align: middle;
text-align: center;
}
<div class="vav-main">
<nav class="navbar navbar-default">
<div class="navbar-header navlogo">
<span>DS</span>
</div>
<div class="navbar-header">
........
</div>
</nav>
</div>
.navheader{
width: 100%;
height: 100px;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
width: 5%;
height: 100%;
background-color: #ffffff;
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
display:table;height:100%;width:100px;
}
.navlogo span a{
display:table-cell;vertical-align:middle;text-align:center;margin:0;
}
<div class="vav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
<span>DS</span>
</div>
</nav>
</div>
Might be you are doing that using bootstrap if so then you could try it like as below, remove span tag as both a and span tags are inline elements, so you could use one if needed.
.nav-main {
width: 100%;
height: 100%;
}
.nav-main > .navheader {
width: 100%;
height: 7.7%;
background-color: #ffffff;
}
.navlogo {
width: 100%;
height: 100%;
background-color: #ffffff;
text-align: center;
}
.navlogo > a {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
display: inline-block;
margin-top: 8px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="nav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
DS
</div>
<div>
</div>
</nav>
</div>
I don't modify on your code, I just write tinny block of code. Hope this will be helpful for you. As you see, the text inside lime block always align center by horizonal and middle by vertical.
$('#header .text').css('left', 'calc(50% - '+$('#header .text').css('width')+' / 2)');
$('#header .text').css('top', 'calc(50% - '+$('#header .text').css('height')+' / 2)');
#header{
width:100%;
height:200px;
border:1px blue solid;
}
#box{
width:30%;
height:80%;
background-color:lime;
text-align:center;
position:relative;
}
#box .text{
border:1px red solid;
position:absolute;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='header'>
<div id='box'>
<div class='text'>abchghjghj</div>
</div>
</div>
I'm struggling with the frontend of my page,
When there is a need for content to scroll I am attempting to keep the sidebar, navbar and title bar in the same place whilst allowing the content to scroll.
I thought I had this working until I added a panel to my page which is now causing an overlap. I've deliberately made my textarea massive below to show this.
I can't directly post images yet so heres a link (Edit now I can):
As you can see I'm also struggling to get my panels content to stretch the width of the panel
JSFiddle: https://jsfiddle.net/duwew6ke/
My css file:
.body-content {
padding-left: 15px;
padding-right: 15px;
padding-top: 200px;
}
body {
font-family: "Helvetica Neue",Roboto,Arial,"Droid Sans",sans-serif;
}
.dl-horizontal dt {
white-space: normal;
}
input,
select,
textarea {
max-width: 280px;
}
#sidebar {
position: fixed;
left: 0;
width: 230px;
height: 100%;
border-right: 0.1px solid rgb(225, 225, 225);
margin-top: 60px;
}
#sidebar .sidebar-brand {
height: 50px;
width: 230px;
font-weight: bold;
padding-top:10px;
display: block;
margin: 0;
border-bottom: 0.1px solid rgb(225, 225, 225);
background-color: #fafafa;
font: 500 20px Roboto,RobotoDraft,Helvetica,Arial,sans-serif;
}
#sidebar .sidebar-brand .search {
display: block;
}
#sidebar .sidebar-brand h2 {
margin: 0;
padding-left: 10px;
padding-top: 10px;
}
#navbarwrapper .navbar-inverse {
background-color: white;
border-bottom: 0.1px solid rgb(225, 225, 225);
font-family: 'Indie Flower', cursive;
height: 60px;
position: fixed;
width: 100%;
}
#navbarwrapper .navbar-brand {
font-size: 2em;
margin-top: 10px;
color: #1976d2;
}
#navbarwrapper .userpicture {
height: 50px;
width: 50px;
}
#navbarwrapper .username {
display: block;
margin-top: 30px;
font-size: 20px;
}
#navbarwrapper .bell {
margin-right: 20px;
}
#navbarwrapper .envelope {
margin-right: 20px;
}
#titlenavwrapper {
margin-left: 230px;
margin-top: 60px;
position: fixed;
width: 100%;
}
#titlenavwrapper .navbar-inverse {
height: 50px;
background-color: #1976d2;
font-size: 25px;
color: whitesmoke;
padding-left: 10px;
padding-top: 7px;
}
.body-content {
margin: 0;
margin-left: 230px;
top: 110px;
background-color: #fafafa;
height: 100%;
}
.body-content h2 {
margin: 0;
}
html, body {
height: 100%;
}
The panel code:
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<div class="panel">
<div class="panel panel-heading">
<i class="fa fa-telegram"></i> Contact Us!
</div>
<div class="panel panel-body">
<form id="contactform" method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group Name">
<label>Name</label>
<input class="form-control" />
</div>
Layout Code:
<div id="sidebar">
<div class="sidebar-brand">
<span class="text-muted text-center"><i class="fa fa-search"></i>Search...</span>
</div>
</div>
<div id="navbarwrapper">
<nav class="nav navbar-inverse navbar-static-top">
<div class="navbar-brand">
Title
</div>
<div class="navbar profile-area">
<img src="~/Content/img/default.jpg" class="userpicture img-circle pull-right" alt="userpicture"/>
<span class="username pull-right"><i class="bell fa fa-bell"></i><i class="envelope fa fa-envelope"></i> Name</span>
</div>
</nav>
</div>
<div id="titlenavwrapper">
<nav class="nav navbar-inverse navbar-static-top">
<div class="navbar-title">
#ViewBag.Title
</div>
</nav>
</div>
You need to add a z-index to #titlenavwrapper
#titlenavwrapper{
z-index:5;
}
click here for demo
I wrote a responsive footer as shown in screen shot:
The text HELP and back icon aren't floating to left, but are struck in middle. How can I move it to left?
Here is the code:
HTML code:
<div id = "footer">
<span id = "logout" class="pull-right">
<span id = "logoutIcon"></span>
<span id = "logoutText">
LOGOUT
</span>
</span>
<span id = "logout1" class="pull-right">
<span id = "logoutIcon1"></span>
<span id = "logoutText1">
HELP
</span>
</span>
</div>
CSS code::
#footer {
background-color: #125e9a;
bottom: 0;
height: 5%;
position: absolute;
width: 100%;
}
#logout1 {
display: block;
height: 100%;
margin-left: 3%;
padding: 2.5%;
width: 30%;
}
#logoutIcon1 {
background-image: url("../JunosImages/mob/back-arrow_normal_tab.png");
background-repeat: no-repeat;
background-size: 100% 100%;
display: block;
float: left;
height: 14px;
margin-top: 2%;
width: 10px;
}
#logoutText1 {
color: #fff;
float: left;
font-size: 14px;
font-weight: 600;
margin-left: 7%;
}
You pulled right both buttons. Just replace pull-right class with pull-left in the second button and swap these buttons.
Also don’t use ID selectors in CSS.
are u use bootstrap so please check the below ans...
class="pull-left";
i would do it like this:
<!DOCTYPE html>
<html>
<head>
<style>
.footer {
background-color: #125e9a;
bottom: 0;
height: 5%;
position: absolute;
width: 100%;
}
.footer-links{
display: block;
float:left;
margin-left: 3%;
padding: 0.5%;
width: 98px;
}
.arrow{
background-color: green;
height: 14px;
margin-top: 2%;
width: 10px;
}
.footer .button-text{
color: #fff;
font-size: 14px;
font-weight: 600;
margin-left: 7%;
}
.footer-links-wrapper{
width: 215px;
}
</style>
</head>
<body>
<div id="footer" class="footer">
<div class="footer-links-wrapper">
<span id="help" class="pull-left footer-links">
<span id="left-arrow" class="arrow left-arrow"> << </span>
<span id="help-text" class="button-text">
HELP
</span>
</span>
<span id="logout" class="pull-right footer-links">
<span id="logout-text" class="button-text">
LOGOUT
</span>
<span id="right-arrow" class="arrow right-arrow"> >> </span>
</span>
</div>
</div>
</body>
</html>
always better to write styles in classes and not by id
use "=" in attributes without spaces
name of classes and ids have to explain what you do (one way of comments)
in your code missing other styles, for look what you did in local browser
I'm currently trying to develop a website. At the moment I'm trying to get the design down, but its giving me quite a tough time.
I have 5 div's. Each one contains two span's, column1 and column2. The div's are block and the span's are inline-block. However, for some reason the div's don't want to align vertically. Any help is appreciated. Also, another thing. Some of the span's inside the div's were replaced with div's. I did this because I planned on using block elements inside of those particular areas and to do that and still validate they had to be div's, not span's.
Below is my current code:
.header {
color: #AEC6CF;
font-family: gabriola;
font-weight: 900;
font-size: 50px;
position: relative;
}
/* ID */
#row1 {
width: 98%;
height: 15%;
position: absolute;
display: block;
}
#row2 {
width: 98%;
height: 2.5%;
position: absolute;
display: block;
}
#row3 {
width: 98%;
height: 70%;
position: absolute;
display: block;
}
#row4 {
width: 98%;
height: 2.5%;
position: absolute;
display: block;
}
#row5 {
width: 98%;
height: 7.25%;
position: absolute;
display: block;
}
#column1 {
border-bottom: 3px solid black;
border-right: 3px solid black;
width: 20%;
height: 100%;
left: 0;
position: absolute;
display: inline-block;
}
#column2 {
border-bottom: 3px solid black;
border-left: 3px solid black;
width: 79.8%;
height: 100%;
right: 0;
position: absolute;
display: inline-block;
}
/* Misc. */
.center {
text-align: center;
}
.right {
text-align: right;
}
.left {
text-align: left;
}
.clearfix {
float: clear;
margin: 0;
padding: 0;
}
<!DOCTYPE html>
<head>
<meta charset=utf-8>
<link type="text/css" rel="stylesheet" href="stylesheet.css">
<title>Design</title>
</head>
<body>
<div id="row1">
<div id="column1" class="clearfix">
</div>
<div id="column2" class="clearfix">
<h1 class="header center">Generic Header</h1>
</div>
</div>
<div id="row2">
<div id="column1" class="clearfix">
</div>
<div id="column2" class="clearfix">
</div>
</div>
<div id="row3">
<span id="column1" class="clearfix">
</span>
<span id="column2" class="clearfix">
</span>
</div>
<div id="row4">
<span id="column1" class="clearfix">
</span>
<span id="column2" class="clearfix">
</span>
</div>
<div id="row5">
<div id="column1" class="clearfix" style="border-bottom: 0px;">
</div>
<div id="column2" class="clearfix" style="border-bottom: 0px;">
</div>
</div>
</body>
</html>
A couple of issues... is there a reason why all of your divs are positioned absolutely? Without specific margins they all just stack ontop of each other since position: absolute; takes them out of the flow of the document. Even relative to the container, they will all be stacked inside of the container.
Secondly, your column widths add up to over 100%. You need to account for the space that the border takes up.
Here is your code without absolutely positioned divs and with adjusted column widths. Hopefully that should get you on the right track.
.header {
color: #AEC6CF;
font-family: gabriola;
font-weight: 900;
font-size: 50px;
position: relative;
}
/* ID */
#row1 {
width: 98%;
height: 15%;
display: block;
}
#row2 {
width: 98%;
height: 2.5%;
display: block;
}
#row3 {
width: 98%;
height: 70%;
display: block;
}
#row4 {
width: 98%;
height: 2.5%;
display: block;
}
#row5 {
width: 98%;
height: 7.25%;
display: block;
}
#column1 {
border-bottom: 3px solid black;
border-right: 3px solid black;
width: 20%;
height: 100%;
left: 0;
display: inline-block;
}
#column2 {
border-bottom: 3px solid black;
border-left: 3px solid black;
width: 73%;
height: 100%;
right: 0;
display: inline-block;
}
/* Misc. */
.center {
text-align: center;
}
.right {
text-align: right;
}
.left {
text-align: left;
}
.clearfix {
float: clear;
margin: 0;
padding: 0;
}
<!DOCTYPE html>
<head>
<meta charset=utf-8>
<link type="text/css" rel="stylesheet" href="stylesheet.css">
<title>Design</title>
</head>
<body>
<div id="row1">
<div id="column1" class="clearfix">
</div>
<div id="column2" class="clearfix">
<h1 class="header center">Generic Header</h1>
</div>
</div>
<div id="row2">
<div id="column1" class="clearfix">
</div>
<div id="column2" class="clearfix">
</div>
</div>
<div id="row3">
<span id="column1" class="clearfix">
</span>
<span id="column2" class="clearfix">
</span>
</div>
<div id="row4">
<span id="column1" class="clearfix">
</span>
<span id="column2" class="clearfix">
</span>
</div>
<div id="row5">
<div id="column1" class="clearfix" style="border-bottom: 0px;">
</div>
<div id="column2" class="clearfix" style="border-bottom: 0px;">
</div>
</div>
</body>
</html>
Basically I'm trying to make the chat messages scrollable. However as of right now the content doesn't seem to be scrollable. When the "chat-messages-wrapper" class was relative it'd scroll just fine however I want the chat messages to appear at the bottom initially which is why I switched it to absolute.
Html:
<div class="chat-widget">
<div class="header">Social Chat</div>
<div class="chat-messages-wrapper">
<div class="chat-message">
<img class="profile-image" src="../Content/images/facebook-profile.png" /> <span class="header-1">
<img class="logo" src="../Content/images/facebook-logo.png" />
<span class="username">Jens Olsen says:</span>
</span> <span class="header-2">
<button class="reply btn btn-primary btn-xs">Reply</button>
<button class="like btn btn-success btn-xs">Like</button>
<button class="spam btn btn-danger btn-xs">Spam</button>
<span class="date">5:03PM</span>
</span>
<div class="text">This is the chat message. This is the chat message.</div>
</div>
<div class="chat-message">
<img class="profile-image" src="../Content/images/facebook-profile.png" /> <span class="header-1">
<img class="logo" src="../Content/images/twitter-logo.png" />
<span class="username">Jens Olsen says:</span>
</span> <span class="header-2">
<button class="reply btn btn-primary btn-xs">Reply</button>
<button class="like btn btn-success btn-xs">Like</button>
<button class="spam btn btn-danger btn-xs">Spam</button>
<span class="date">5:03PM</span>
</span>
<div class="text">This is the chat message. This is the chat message.</div>
</div>
<div class="chat-message">
<img class="profile-image" src="../Content/images/default-avatar.png" /> <span class="header-1">
<span class="username">Jens Olsen says:</span>
</span> <span class="header-2">
<button class="reply btn btn-primary btn-xs">Reply</button>
<button class="like btn btn-success btn-xs">Like</button>
<button class="spam btn btn-danger btn-xs">Spam</button>
<span class="date">5:03PM</span>
</span>
<div class="text">This is the chat message. This is the chat message.</div>
</div>
</div>
<div class="reply-box">
<input class="reply-text" placeholder="Type your message here..." />
<button class="btn btn-primary reply-button">Send</button>
</div>
</div>
Css:
.chat-widget {
position: fixed;
right: 5px;
bottom: 5px;
height: 95%;
width: 300px;
background-color: #FFF;
border: solid 3px #3B5998;
overflow: hidden;
}
.chat-widget .header {
text-align: center;
font-size: 18px;
color: #FFF;
background-color: #3B5998;
font-weight: bold;
padding-top: 5px;
padding-bottom: 5px;
}
.header {
position: relative;
z-index: 2;
width: 100%;
}
.chat-messages-wrapper {
position: absolute;
bottom: 40px;
padding-left: 7px;
padding-right: 7px;
height: auto;
overflow-y: auto;
}
.chat-message {
padding-top: 5px;
position: relative;
border-bottom: solid 1px #000;
overflow-y: auto;
}
.chat-message .profile-image {
height: 48px;
width: 48px;
border: solid 1px #000;
margin-right: 5px;
}
.chat-message > .header-1 {
position: absolute;
height: 20px;
}
.chat-message > .header-1 .logo {
width: 75px;
height: 20px;
}
.chat-message > .header-1 .username {
font-weight: bold;
}
.chat-message > .header-2 {
position: absolute;
top: 30px;
height: 20px;
}
.chat-message > .header-2 > .reply {
width: 50px;
}
.chat-message > .header-2 > .like {
width: 50px;
}
.chat-message > .header-2 > .spam {
width: 50px;
}
.chat-message > .header-2 .date {
font-style: italic;
position: relative;
right: 0px;
}
.chat-message .text {
position: relative;
margin: 5px;
}
.chat-message:last-child {
border-bottom: 0px;
}
.reply-box {
overflow-y: auto;
position: absolute;
bottom: 5px;
}
.reply-box .reply-text {
width: 70%;
height: 32px;
}
.reply-box .reply-button {
width: 25%;
}
Here's a JSFiddle with the entire code:
http://jsfiddle.net/5GCE5/1/
In order to get overflow-y to work, you need to specify an explicit (min/max) height for the .chat-messages-wrapper element.
However, since the box is positioned absolutely, you could play with top and bottom properties to achieve the same effect:
Example Here
.chat-messages-wrapper {
position: absolute;
padding-left: 7px;
padding-right: 7px;
/* height: auto; */
bottom: 40px; /* = height of bottom element */
top: 32px; /* = height of top element */
overflow-y: auto;
}
You need to give .chat-messages-wrapper a max-height
http://jsfiddle.net/5GCE5/6/