I want this button on top of div box - html

I want this button on top of the div box, but I have no idea what css code I should use.
This below is what I want to do, but I have no idea how to do
What I want to do
I tried a lot of different ways including padding and margin, but I can't get it to work.
.wrapper {
background: white;
}
.TEST1{
float:right;
position: relative;
}
<div class="wrapper row"
style="padding: 10px 30px; position: fixed; bottom: 0; border-top: 1px solid #ccc; box-shadow: 0px 2px 10px #888888;">
<button type="button" class="TEST1" id="TEST!">Close</button>
<p class="col-md-10"
astyle="color: #262626; font-size: 12px; line-height: 17px; letter-spacing: .1px; padding: 0 30px 0 0;">TEST TEST TEST
</p>
<button class="col-xs-12 col-md-2 btn-close-cookie-notification"
style="background-color: black; border: none; color: white; padding: 13px; cursor: pointer; max-height: 40px; font-size: 12px; position: relative;">OK</button>
</div>

Please, Check this code
HTML File
<div class="wrapper">
<div
class="row"
style="
padding: 10px 30px;
position: fixed;
bottom: 0;
border-top: 1px solid #ccc;
box-shadow: 0px 2px 10px #888888;
"
>
<button type="button" class="TEST1" id="TEST!">Close</button>
<p
class="col-md-10"
astyle="color: #262626; font-size: 12px; line-height: 17px; letter-spacing: .1px; padding: 0 30px 0 0;"
>
TEST TEST TEST
</p>
<button
class="col-xs-12 col-md-2 btn-close-cookie-notification"
style="
background-color: black;
border: none;
color: white;
padding: 13px;
cursor: pointer;
max-height: 40px;
font-size: 12px;
position: relative;
"
>
OK
</button>
</div>
</div>
CSS File
.wrapper {
background: white;
position: relative;
}
.TEST1 {
position: absolute;
top: -10px;
right: -10px;
z-index: 999;
}
Demo link: https://stackblitz.com/edit/web-platform-nd9jej?file=styles.css
Note: Please add top and right css according your usability.

.TEST1 {
position: absolute;
top: -22px;
right: 0;
}

Related

How can I left align and right align my chat bubbles?

I have created two chat bubbles which one of them I need to be left aligned and other one I need to be right aligned .As of now my css grow both till the end like below image .
As of now I do not want to hardcode the width and want the bubble to grow with chat text and both one should be left aligned and other one should be right aligned like below:
CSS:
.speech-wrapper{
padding: 5px 6px;
}
.chatbox {
padding: 5px;
margin-left: 5px;
margin-right: 5px;
margin-top:0px;
background: #075698;
color: #FFF;
position: relative;
border-radius: 10px;
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
box-shadow: 0 8px 6px -6px black;
}
.chatbox_other{
height:auto;
padding: 5px;
margin-left: 5px;
margin-right: 5px;
margin-top:0px;
background: #DCDCDC;
color: #000;
position: relative;
border-radius: 10px;
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
box-shadow: 0 8px 6px -6px black;
}
.name_other{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #1970b0;
}
.name_other1{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #ba006e;
}
.name_other2{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #007670;
}
.name_other3{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #3b0256;
}
.name_other4{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #00512b;
}
.name_other5{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #a91024;
}
.name_other6{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #b8471b;
}
.name_other7{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #7f1c7d;
}
.timestamp_other{
font-size: 11px;
position: absolute;
bottom: 0px;
right: 10px;
text-transform: uppercase; color: #999
}
.timestamp{
font-size: 11px;
position: absolute;
bottom: 0px;
right: 10px;
text-transform: uppercase; color: #fff
}
/* speech bubble 13 */
.name{
font-weight: 600;
font-size: 12px;
margin: 0px 0px 9px;
color: #ffffff;
}
.triangle.left-top:after {
content: ' ';
position: absolute;
width: 0;
height: 0;
left: -10px;
right: auto;
top: 0px;
bottom: auto;
border: 22px solid;
border-color: #DCDCDC transparent transparent transparent;
z-index: -1;
}
.triangle.right-top:before {
content: ' ';
position: absolute;
width: 0;
height: 0;
left: auto;
right: -10px;
top: 0;
bottom: auto;
border: 32px solid;
border-color: #075698 transparent transparent
transparent;
z-index: -1;
}
.alt{
margin: 0 0 0 60px;
}
HTML:
<div class="speech-wrapper">
<div class="chatbox triangle right-top alt">
<div class="txt">
<p class="name">Apple TestUser1</p>Hi<span class="timestamp">10:20 pm</span></div>
</div>
<div class="speech-wrapper">
<div class="chatbox_other triangle left-top">
<div class="txt">
<p class="name">Apple TestUser1</p>Hi<span class="timestamp">10:20 pm</span>
</div>
</div>
</div>
</div>
I have tried uisng float left but while reducing the windows size the chat started overlapping on eachother
For testing out try below link
https://codepen.io/rajesh-kumar-dash/pen/KbvqQX
I think using float: right; for the right bubble and for the left bubble: float: left; with width: auto; should work
The "dirty" way to do it is by adding a after the divs just to clear the float:
<div class="speech-wrapper"><div class="chatbox triangle right-top alt"><div class="txt"><p class="name">Apple TestUser1</p>Hi<span class="timestamp">10:20 pm</span></div></div>
<div style="clear:both"></div>
<div class="speech-wrapper"><div class="chatbox_other triangle left-top"><div class="txt"><p class="name">Apple TestUser1</p>Hi<span class="timestamp">10:20 pm</span></div></div>
<div style="clear:both"></div>
The cleaner way to do it is called "Clearfix". I suggest you take a look on these two links to understand it and use on your code:
https://www.w3schools.com/css/css_float.asp
https://css-tricks.com/snippets/css/clear-fix/
If you want the size of your box as large as the text in it, you have to set "display: inline-block";
To make sure your box wont get bigger then a certain size use "max-width".
With "overflow-wrap: break-word" your text breaks if it reaches the max-width.

Html5 Border-Radius Reverse Fill

I want to achieve drop-down button as per following design image. See drop-down menu starts just after middle of button. My problem is that button has transparent background to utilize background image from root parent div.
So far I have achieved following image. As I said above, I want to achieve white edges outside of border-radius.
.dropdown-header {
border-top-left-radius: 20px;
border-top-right-radius: 20px;
width: 210px;
height: 185px;
margin: auto;
}
.div-user-header {
width: 210px;
margin: auto;
position: relative;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
}
.div-user-header-1 {
width: 206px;
height: 24px;
border: 2px solid #9CB2C7;
border-radius: 20px;
display: inline-block;
text-align: center;
padding-top: 5px;
}
.div-user-header-1 a {
text-decoration: none;
color: #FCCC00;
display: block;
}
.div-user-header-list {
position: absolute;
background-color: white;
height: 170px;
width: 210px;
}
.div-user-header-2 a {
text-decoration: none;
font-size: 12px;
color: #8C8C8C;
}
.div-user-header-2 {
height: 40px;
padding: 12px 15px;
}
.div-user-header-3 a {
text-decoration: none;
font-size: 12px;
color: #8C8C8C;
}
.div-user-header-3 {
height: 40px;
padding: 12px 15px;
}
.div-add-profile-card {
padding: 0px 15px;
}
.div-add-profile-card a {
text-decoration: none;
color: #8C8C8C;
font-size: 10px;
padding: 12px;
display: block;
border-top: 1px solid #D6D6D6;
}
<div class="dropdown-header">
<div class="div-user-header">
<div class="div-user-header-1">
ProfileUser 01
</div>
<div class="div-user-header-list">
<div class="div-user-header-2">
<img src="../../../assets/images/avtar2.png" width="34px" height="34px" style="padding-right: 5px; vertical-align: middle" />
ProfileUser 01
</div>
<div class="div-user-header-3">
<img src="../../../assets/images/user-02.png" width="30px" height="30px" style="padding-right:5px; vertical-align: middle" />
ProfileUser 02
</div>
<div class="div-add-profile-card">
+ Add Profile Cards
</div>
</div>
</div>
Any suggestion would be really helpful.
Use ::after ::before pseudo elements for the dropdown and apply separate background-image as marked in the image. Apply position:absolute and align then in the top left and right corners based on the design.
It's very simple. You have achieved almost 99%. Just add below styles to your CSS of .div-user-header-list as below:
.div-user-header-list {
position: absolute;
background-color: white;
height: 170px;
width: 210px;
padding-top: 20px;
margin-top: -20px;
z-index: -1;
}
See the updated fiddle here: https://jsfiddle.net/8ukj3wy1/1/
Check this one out:
https://jsfiddle.net/sLy7fnzg/
Essentially use a negative margin to move the .div-user-header-list up and use relative positioning to enable z-indexes.
Also, to resolve the issue with the half border, remove the border from the .div-user-header-1 and add a whole element as a ::before to the .div-user-header like so:
.div-user-header::before {
content: "";
background: #9CB2C7;
width: 210px;
height: 30px;
display:block;
position: absolute;
top: 0;
left: 0;
border-radius: 20px;
z-index: 1;
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<style>
body{
background-color: grey;
}
.dropdown-header {
border-top-left-radius: 20px;
border-top-right-radius: 20px;
width: 210px;
height: 203px;
margin: auto;
overflow: hidden;
/*background-color: #fff;*/
}
.div-user-header-list:before,
.div-user-header-list:after {
content: "";
position: absolute;
height: 10px;
width: 20px;
bottom: 0;
}
.div-user-header-list:before {
/*right: -20px;*/
left: 1px;
top: -10px;
border-radius: 0 0 0 10px;
-moz-border-radius: 0 0 0 10px;
-webkit-border-radius: 0 0 0 10px;
-webkit-box-shadow: -10px 0 0 0 #fff;
box-shadow: -10px 0 0 0 #fff;
}
.div-user-header-list:after {
/*left: -20px;*/
right: 1px;
top: -10px;
border-radius: 0 0 10px 0;
-moz-border-radius: 0 0 10px 0;
-webkit-border-radius: 0 0 10px 0;
-webkit-box-shadow: 10px 0 0 0 #fff;
box-shadow: 10px 0 0 0 #fff;
}
.div-user-header {
width: 210px;
margin: auto;
position: relative;
border-radius: 20px;
}
.div-user-header-1 {
width: 206px;
height: 24px;
border: 2px solid #9CB2C7;
border-radius: 20px;
display: inline-block;
text-align: center;
padding-top: 5px;
}
.div-user-header-1 a {
text-decoration: none;
color: #FCCC00;
display: block;
}
.div-user-header-list {
position: absolute;
background-color: white;
height: 170px;
width: 210px;
/*margin-top: -14px;
z-index: -9;
padding-top: 14px;*/
}
.div-user-header-2 a {
text-decoration: none;
font-size: 12px;
color: #8C8C8C;
}
.div-user-header-2 {
height: 40px;
padding: 12px 15px;
}
.div-user-header-3 a {
text-decoration: none;
font-size: 12px;
color: #8C8C8C;
}
.div-user-header-3 {
height: 40px;
padding: 12px 15px;
}
.div-add-profile-card {
padding: 0px 15px;
}
.div-add-profile-card a {
text-decoration: none;
color: #8C8C8C;
font-size: 10px;
padding: 12px;
display: block;
border-top: 1px solid #D6D6D6;
}
</style>
</head>
<body>
<div class="dropdown-header">
<div class="div-user-header">
<div class="div-user-header-1">
ProfileUser 01
</div>
<div class="div-user-header-list">
<div class="div-user-header-2">
<img src="../../../assets/images/avtar2.png" width="34px" height="34px" style="padding-right: 5px; vertical-align: middle" />
ProfileUser 01
</div>
<div class="div-user-header-3">
<img src="../../../assets/images/user-02.png" width="30px" height="30px" style="padding-right:5px; vertical-align: middle" />
ProfileUser 02
</div>
<div class="div-add-profile-card">
+ Add Profile Cards
</div>
</div>
</div>
</body>
</html>

"Responsive" buttons with ::before and ::after shape

By responsive I mean that they still look good with slightly longer text and don't have fixed width.
I am trying to make buttons that look exactly like in image below, but I can't get them to be the right width. I thought adding padding on left and right side would do it, but that doesn't work with the "ADD" button. My task is to convert a .psd to html/css pixel perfect which is kind of dumb and results in bad code.
Fiddle: https://jsfiddle.net/emils/9g7cn7eh/
Buttons:
Button:
<div class="btn-container">
<button class="action-btn" type="submit">Add</button>
</div>
Styling:
.btn-container {
position: relative;
padding-bottom: 20px;
}
.action-btn {
padding: 4px 9px 4px 20px;
color: #f5f8f9;
font-size: 0.9375em;
letter-spacing: 0.4px;
text-transform: uppercase;
background-color: #aecacc;
border: 0;
}
.action-btn:before {
content: "";
position: absolute;
width: 0;
height: 0;
top: 0;
margin-left: -20px;
border-top: 14px solid transparent;
border-bottom: 14px solid transparent;
border-left: 7px solid #f4f4f4;
}
.action-btn:after {
content: "";
position: absolute;
width: 0;
height: 0;
top: 0;
margin-left: 8px;
border-top: 13px solid transparent;
border-bottom: 13px solid transparent;
border-left: 15px solid #aecacc;
}
Add position: relative to the buttons, and use right/left to move the pseudo elements.
JSfiddle: link
.btn-container {
position: relative;
padding-bottom: 20px;
}
.action-btn {
padding: 4px 9px 4px 20px;
color: #f5f8f9;
font-size: 0.9375em;
letter-spacing: 0.4px;
text-transform: uppercase;
background-color: #aecacc;
border: 0;
position: relative; /* we need this for the pseudo elements positioning */
}
.action-btn:before {
content: "";
position: absolute;
width: 0;
height: 0;
top: 0;
left: 0;
/*margin-left: -20px;*/
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
border-left: 7px solid #f4f4f4;
}
.action-btn:after {
content: "";
position: absolute;
width: 0;
height: 0;
top: 0;
right: -15px;
/*margin-left: 8px;*/
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
border-left: 15px solid #aecacc;
}
<div class="btn-container">
<button class="action-btn" type="submit">Add</button>
</div>
<div class="btn-container">
<button class="action-btn" type="submit">View Basket</button>
</div>
<div class="btn-container">
<button class="action-btn" type="submit">View All (15)</button>
</div>
<div class="btn-container">
<button class="action-btn" type="submit">Checkout</button>
</div>

How can I dynamically place a "floating action button" between two seams?

I´d like to know how I can place a "floating action button" as Google calls it (Reference: Floating Action Button, Google Material Design) dynamically between two "seams" - depending on the element it is placed in.
In my case I use simple HTML container classes with few CSS rules to create Google Cards.
The HTML and CSS Code I used here looks like the following:
/* Google Material Design (Paper-) Cards */
*.card {
position: relative;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
color: var(--grey800);
background-color: var(--grey50);
}
*.card .card-header {
position:relative;
padding: 20px 16px;
border-radius: 2px 2px 0px 0px;
-moz-border-radius: 2px 2px 0px 0px;
-webkit-border-radius: 2px 2px 0px 0px;
}
*.card .card-header > span.card-title {
font-family: 'Roboto', sans-serif;
font-size: 24px;
font-weight: 300;
line-height: 1.5em;
}
*.card .card-header > span.card-subtitle {
display: block;
font-family: 'Roboto', sans-serif;
font-size: 15px;
font-weight: 300;
line-height: 1.5em;
color: var(--grey700);
}
*.card .rich-media {
position: relative;
}
*.card .rich-media > img {
display: block;
position: relative;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
border: 0;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
*.card .card-header ~ .rich-media > img {
border-radius: 0px 0px 2px 2px;
-moz-border-radius: 0px 0px 2px 2px;
-webkit-border-radius: 0px 0px 2px 2px;
}
*.card .rich-media > span.card-title {
position: absolute;
left: 0;
bottom: 0;
padding: 20px 16px;
font-family: 'Roboto', sans-serif;
font-size: 24px;
font-weight: 300;
color: var(--white);
}
*.card .card-content {
padding: 20px 16px;
}
*.card .card-content + .card-content {
border-top: 1px solid rgba(160, 160, 160, 0.2);
}
*.card .card-action {
position: relative;
padding: 20px 16px;
border-top: 1px solid rgba(160, 160, 160, 0.2);
border-radius: 0px 0px 2px 2px;
-moz-border-radius: 0px 0px 2px 2px;
-webkit-border-radius: 0px 0px 2px 2px;
background-color: inherit;
}
*.card .card-action > a {
transition: color .3s ease;
font-family: 'Roboto', sans-serif;
font-size: 17px;
font-weight: 400;
line-height: 1.5em;
text-decoration: none;
text-transform: uppercase;
color: var(--orange500);
}
*.card .card-action > a:hover {
color: var(--orange200);
}
/* Google Material Design Buttons */
*.btn {
/* ... */
}
*.floating-action {
width: 56px;
height: 56px;
text-align: center;
border-radius: 50%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
}
*.floating-action .material-icons {
position: relative;
top: 50%;
transform: translateY(-50%);
}
<div class="card" data-elevation="1">
<!-- card header -->
<div class="card-header">
<span class="card-title">Card Title</span>
<span class="card-subtitle">Card Subtitle</span>
</div>
<!-- card image -->
<div class="rich-media">
<image src="mountains.jpg"></image>
</div>
<!-- card content -->
<div class="card-content align-left">
<!-- floating action button -->
<div class="floating-action bg-orange500" data-elevation="2">
<i class="material-icons txt-white">mail_outline</i>
</div>
<p class="flowtext">
The European languages are members of the same family. Their separate existence is a myth. For science, music, sport, etc, Europe uses the same vocabulary.
</p>
</div>
<!-- card actions -->
<div class="card-action">
This is a link
</div>
</div>
What I am trying to approach is a way of placing the seen button (the little one with the envelope icon on it) between (the previous) two contiguous borders like shown with a red dot below:
It is also possible to add multiple content containers; In this case the placed buttons should also be placed between the previous contiguous container borders.
In the last case shown above the button would be placed inside the 2nd card-container element.
Maybe some jQuery calculation would help. What do you think? What is a good practice to achieve the required layout?
In this Page: http://materializecss.com/cards.html you can access cards examples and one of them is placing the FAB button between title and content of the card. All you have to do is to see the CSS they show in source code.
<div class="row">
<div class="col s12 m6">
<div class="card">
<div class="card-image">
<img src="images/sample-1.jpg">
<span class="card-title">Card Title</span>
<a class="btn-floating halfway-fab waves-effect waves-light red">
<i class="material-icons">add</i>
</a>
</div>
<div class="card-content">
<p>I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.</p>
</div>
</div>
</div>
</div>
.btn-floating.btn-large i {
line-height: 56px;
}
.btn-large i {
font-size: 1.6rem;
}
.btn-floating i {
width: inherit;
display: inline-block;
text-align: center;
color: #fff;
font-size: 1.6rem;
line-height: 40px;
}
.btn-floating.btn-large.halfway-fab {
bottom: -28px;
}
.btn-floating.halfway-fab {
position: absolute;
right: 24px;
bottom: -20px;
}
.btn-floating.btn-large {
width: 56px;
height: 56px;
padding: 0;
}

The anchor tag link is not working

I am implementing notifications. I have integrated the whole backend with the front end.
I have Notification HTML as :
<span id="notification_count" style="display: none"></span>
<img alt="" src="assets/img/notification-icon.jpg">
<div id="notificationContainer">
<div id="notificationTitle">Notifications</div>
<div id="notificationsBody">
<table style="text-align: center;">
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
<tr>
123
</tr>
<hr>
</table>
</div>
<div id="notificationFooter"></div>
</div>
And CSS :
#nav{list-style:none;margin: 0px;padding: 0px;}
#nav li {
float: left;
margin-right: 20px;
font-size: 14px;
font-weight:bold;
}
#nav li a{color:#333333;text-decoration:none}
#nav li a:hover{color:#006699;text-decoration:none}
#notification_li
{
position:relative
}
#notificationContainer
{
background-color: #fff;
border: 1px solid rgba(100, 100, 100, .4);
-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
overflow: visible;
color : #ffffff;
position: absolute;
top: 30px;
margin-left: -170px;
width: 400px;
z-index: -1;
display: none; // Enable this after jquery implementation
}
// Popup Arrow
#notificationContainer:before {
content: '';
display: block;
position: absolute;
width: 0;
height: 0;
border: 10px solid black;
border-color: transparent transparent white;
margin-top: -20px;
margin-left: 188px;
}
#notificationTitle
{
text-align: center;
font-weight: bold;
padding: 8px;
font-size: 12px;
background-color: #ffffff;
border-bottom: 1px solid #dddddd;
color: #555;
}
#notificationsBody
{
padding: 33px 0px 0px 0px !important;
min-height:300px;
}
#notificationFooter
{
background-color: #e9eaed;
text-align: center;
font-weight: bold;
padding: 8px;
font-size: 12px;
border-top: 1px solid #dddddd;
}
#notification_count
{
padding: 3px 7px 3px 7px;
background: #cc0000;
color: #ffffff;
font-weight: bold;
margin-left: 25px;
border-radius: 9px;
-moz-border-radius: 9px;
-webkit-border-radius: 9px;
position: absolute;
margin-top: -11px;
font-size: 11px;
}
But the a tags in the notificationsBody are not working. On clicking these a tags nothing is happening.
Please tell what is the issue. There might some problem in the z index. Please help me out.
You can use onclick event to open a link
123
Your HTML is invalid and is a likely cause of your problem.
You aren't allowed to put links as children of table rows. Only table cells may go there.
Use a validator and fix the errors.