CSS align chat boxes to bottom of screen - css

I have several chat boxes and other div elements that need to be positioned at the bottom of the screen, aligned to the right.
Problem #1: Elements do not have the same height, and the smaller ones are vertically aligned with the top of the highest element. Fiddle: http://jsfiddle.net/sd69jdxp/
#container { position: fixed; bottom:0; left:0; right:0; }
.chat { border: 1px solid #999; float: right; position: relative; margin: 0 5px; }
Problem #2: Using the approach of
display: inline-block; vertical-align: bottom;
to align divs to the bottom of the page, the links (anchors) over the first (smallest) chat box are not clickable, as the parent container overlaps the links. And it's not possible to set a lower z-index to the chat container than to the content behind, since the chat boxes are children of the chat container and they MUST have a higher z-index than the page content. How can this issue be solved?
Fiddle showing this issue: http://jsfiddle.net/xw689yv8/
Summary
How can I force all divs to be aligned with the bottom right of the screen, without having the chat container (parent div of chat boxes) overlap the content in the page behind the chat boxes, thus making it unclickable?

Use pointer-events: none on the container; elements underneath it will now be clickable.
Arrange the chat boxes inside the fixed container with display: inline-block and vertical-align: bottom.
The chat boxes get pointer-events: auto so they and their children can be clicked.
For IE10 and below, check out this answer to an older question to transfer click events.
Example
See it full screen and select the text input sitting underneath the invisible container.
.under {
position: absolute;
bottom: 200px;
right: 200px;
}
#container {
position: fixed;
bottom: 0;
right: 0;
pointer-events: none;
}
.chat {
border: 1px solid #999;
display: inline-block;
vertical-align: bottom;
position: relative;
margin: 0 5px;
pointer-events: auto;
}
.title {
padding: 0.5em;
background-color: blue;
color: white;
}
.text {
padding: 10px;
}
<div class="under">
<input type="text" value="select me!" />
</div>
<div id="container">
<div class="chat">
<div class="title">This is the chat title</div>
<div class="text">
<p>Text 1</p>
<p>Text 2</p>
<p>Text 3</p>
</div>
<div class="chatbox">
<input type="text" />
</div>
</div>
<div class="chat">
<div class="title">This is the chat title</div>
<div class="text" style="height:250px">
<p>Text 1</p>
<p>Text 2</p>
<p>Text 3</p>
</div>
<div class="chatbox">
<input type="text" />
</div>
</div>
</div>

I am not sure how you want to align them so I put them over each other.
http://jsfiddle.net/ouu94tfv/
#container { position: fixed; bottom:0; left:0; right:0; }
.chat { border: 1px solid #999; right:0; position: absolute; bottom: 0; margin: 0 5px; display:inline-block; float:right;}
.title { padding: 0.5em; background-color: blue; color: white; }
.text { padding: 10px; }

Related

Remove excess padding after transformY on predecessor's ::after

(Wow, that was a lousy title!)
I created a little quarter-circle to display after a div. I then used transformY to move it back up the div so that some content overlaps, which is the user's design requirement.
However, doing so leaves some excess space at the bottom of the div... the div retains the full height after the transform. I'd like to reduce that height.
I'm working in a page builder (ClickFunnels). Here's the link: https://www.goupperpeninsula.com/get-your-arts-on
Here's the CSS:
#section-1852710000::after,
#section-1852710000::before {
content: '';
position: relative;
display: block;
background: #ffe121;
width: 285px;
height: 285px;
}
#section-1852710000::after {
border-top-right-radius: 285px;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
Here's the space I'd like to eliminate:
I feel like I'm missing something obvious, I'm just not quite sure what it is!
This is expected. A transform is purely visual and does not affect layout. I'd try negative margin instead.
Here's a demo of the different behaviours I keep around.
* {
box-sizing: border-box;
}
h3 {
text-align: center;
}
.page {
margin: 0 auto;
text-align: center;
}
.wrapper {
border: 5px solid black;
margin: 5px;
display: inline-block;
background: lightblue;
vertical-align: top;
}
.box {
width: 100px;
height: 350px;
background: lightgrey;
border: 1px solid grey;
padding: 10px;
text-align: center;
}
.position {
position: relative;
top: -25px;
}
.margin {
margin-top: -25px;
}
.transform {
transform: translateY(-25px);
}
<h3>DEMONSTRATING THE DIFFERENCE BETWEEN RELATIVE POSITIONING AND POSITIVE/NEGATIVE MARGINS AND TRANSFORMS</h3>
<div class="page">
<div class="wrapper">
<div class="box">
<p>This box is the specimen for comparison purposes.</p>
<p>It is a grey box inside a blue box with a black border.</p>
</div>
</div>
<div class="wrapper">
<div class="box position">
<p>This grey box is moved using relative positioning.</p>
<p>The page remembers where it was and allocates that space as though the element was still there.</p>
</div>
</div>
<div class="wrapper">
<div class="box margin">
<p>This grey box is moved using negative margin.</p>
<p>See how the wrapper div has 'shrunk'?</p>
↓ ↓
</div>
</div>
<div class="wrapper">
<div class="box transform">
<p>This grey box is moved using a transform.</p>
<p>The page remembers where it was and allocates that space as though the element was still there.</p>
</div>
</div>
</div>

Resizable container with a contained item that overflow. Combine overflow:visible with resizability

I need to create a container div with a pulled-up toggle button (but this could be also a simple span, a label or everything else), but that can be also re-sizable.
Unfortunately (https://css-tricks.com/almanac/properties/r/resize/):
Super important to know: resize does nothing unless the overflow property is set to something other than visible, which is its initial value for most elements.
I tried to write a simple example to compare limits of each conflicting properties (below only an extract):
<div class="container">
<button>Toggle</button>
<div class="content">...</div>
</div>
<div class="container overflow-hidden">
<button>Toggle</button>
<div class="content">...</div>
</div>
.container {
border:solid 1px red;
position:relative;
resize:horizontal;
}
.overflow-hidden {
overflow:hidden;
}
button {
position:absolute;
top:-20px;
}
I can't figure out how to solve this problem, so how to have a resizable container that can show an overflowed item (Possibly with only CSS)?
how to have a resizable container that can show an overflowed item
For resize to work, the element need an overflow other than visible, so the answer to that is no.
I need to create a container div with a pulled-up toggle button
If you alter your markup a little, you can do like this
Fiddle demo
Stack snippet
.container {
position: relative;
display: inline-block;
}
.overflow-hidden {
border: solid 1px red;
width: 50%;
height: 80%;
margin-top: 18px;
resize: horizontal;
padding: 20px;
overflow: hidden;
}
button {
position: absolute;
top: 0;
left: 0;
}
.content {
border: solid 1px blue;
height: 100px;
}
<div class="container">
<button>Toggle</button>
<div class="overflow-hidden">
<div class="content">
WITH "overflow:hidden":
<br> "resize" feature is available <strike>but pulled-up button is obviously semi-hidden</strike>
</div>
</div>
</div>

I can't align Images horizontally

I can't seem to make my images align side by side, they just keep stacking on top of each other. I have only enough knowledge to fumble my way through with instructions and I'm stuck here.
HTML:
<div class='sticky-bar'>
<div class='sticky-bar-inner'>
<div>
<a href='https://www.facebook.com/salvageinteriors' target='_blank'>
<img src='img.png' />
</a>
</div>
</div>
</div>
I cant seem to get the rest of the code in here, but it just keeps repeating the above.
CSS:
.sticky-bar {
background: none repeat scroll 0 0 #FFFFFF;
bottom: 0;
color: #000000;
font-weight: 700;
left: 10px;
margin: 9px;
opacity: 0.6;
position: fixed;
width: 45px;
z-index: 62;
}
.sticky-bar-inner {
display: inline-block;
margin-left:auto;
padding: 20px 0;
text-align: left;
width:90%;
}
Try this:
Use float:left property. It will use to align div's side by side and when the parent width is reached then , the images will align in next line.
HTML:
<div class='sticky-bar'>
<div class='sticky-bar-inner'>
<div class="inner-divs">
<a href='https://www.facebook.com/salvageinteriors' target='_blank'>
<img src='img.png' />
</a>
</div>
</div>
</div>
CSS:
Set width for .sticky-bar-inner class
.sticky-bar-inner {
padding: 20px 0;
width:500px;
}
and set float:left property to inner image divs.
.inner-divs{
float:left;
}

position: fixed overlapping page

Here is the fiddle. I am making a grocery list web app, and I am making the top div a fixed position. When I do this, the div seems to overlap the rest of the page. I have tried using two positions in the css (position: relative; position: fixed) but this doesn't let the div stay fixed.
CSS (for the div):
#top {
width: 100%;
height: 40px;
background: #96f226;
text-align: center;
font-size: 30px;
color: #252525;
position: relative;
position: fixed;
}
HTML (for the div):
<div id='top'>Kitchen List</div>
Wrap your content with div and give it the margin-top to the same height as your fixed content.
SEE DEMO HERE
HTML
<div id='top'>Kitchen List</div>
<br />
<div class="container">
<input type='text' id='input'>
<button id='click'>Add</button>
<ol></ol>
<div id='error'>Please enter a grocery item
<br />
<button id='eb'>Close</button>
</div>
</div>
CSS
.container {
margin-top: 50px;
}
You need to add another div to wrap the content with a margin-top.
DEMO
http://jsfiddle.net/sZaxc/8/
HTML
<div id='main'>
<!-- inputs etc -->
</div>
CSS
#main {
margin-top: 50px;
}
I also added a z-indexand top: 0to your #top-div - just in case.
It's because you have two positions. Remove one and make it:
#top {
width: 100%;
height: 40px;
background: #96f226;
text-align: center;
font-size: 30px;
color: #252525;
position: fixed;
}

CSS: Positioning a box over top over a main div

I have the following HTML with the div.logo centered in the middle.
What would be the easiest cross browser solution to allow me to put another box contactDetails onto the left or right but retain the centered image?
HTML:
<div id="page-wrap">
<header>
<div id="logo">
<img src="_assets/images/logo.png" width="500" height="518"/>
<h3>New Website Soon</h3>
</div><!--END logo-->
<div id="contactDetails">
<p>Content</p>
</div>
</header>
</div><!--END page-wrap-->
CSS:
*{
padding: 0;
margin: 0;
}
body{
background:url('../images/background.png') repeat;
margin: 0 auto;
}
div.page-wrap,header,div.logo,h1{
font-family: arial;
text-align: center;
margin:0;
}
div.page-wrap,header,div.logo,img{
border-radius: 5px;
}
div.contactDetails{
float: left;
margin: 0;
}
Position the contact box absolutely.
For what it's worth, none of your CSS above will work because you're using a dot to signify the class of the div, rather than a # pound sign to signify ID of the div (div.logo corresponds to <div class="logo">, div#logo corresponds to <div id="logo">)
#page-wrap {
/* parents of absolutely positioned elements must have a position */
position: relative;
}
#contactDetails {
position: absolute;
top: 0;
right: 0;
/* you could use 'left: 0;' instead, to move to the left edge */
width: 300px;
}

Resources