I am trying to justify some elements inside core-toolbar but I cannot get it to work.
here is my code:
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
box-sizing: border-box;
}
#core_card {
position: absolute;
width: 300px;
height: 300px;
border-top-left-radius: 2px;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
border-bottom-left-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.0980392) 0px 2px 4px, rgba(0, 0, 0, 0.0980392) 0px 0px 3px;
left: 440px;
top: 90px;
background-color: rgb(255, 255, 255);
}
#core_toolbar {
right: 0px;
color: rgb(255, 255, 255);
fill: rgb(255, 255, 255);
background-color: rgb(79, 125, 201);
}
#div {
display: block;
}
#core_icon_button {
display: block;
}
</style>
<core-card id="core_card" layout vertical>
<core-toolbar id="core_toolbar" horizontal layout justified>
<div id="div1">div 1</div>
<div id="div2">div 2</div>
<div id="div">Toolbar</div>
</core-toolbar>
</core-card>
</template>
Code result
Expected result
The issue is that the content you place inside of the core-toolbar is being pulled into a child div inside of core-toolbar's Shadow DOM.
<core-toolbar>
#shadow-root
...
<div id="topBar" class="toolbar-tools" center horizontal layout>
<content></content> <!-- your content is inside of here -->
</div>
Your layout attributes are not being applied to this child div, so you don't get the layout you'd expect.
The easiest way to get the layout you're after is to tell the child divs to flex
<core-toolbar>
<div flex>Foo</div>
<div flex>Bar</div>
<div>Baz</div>
</core-toolbar>
Here's a jsbin example
Related
I have no idea what would fix this.
https://jsfiddle.net/eL5gn73s/
That big one is a div, the small ones are the buttons that have shrunk.
The button should be the same size as the div, not the other way around.
After changing from a div to a button, the button shrunk smaller than the size of the div that was 47px.
.box {
position: relative;
background: red;
width: 47px;
height: 47px;
border-radius: 4px;
border-width: 4px;
border-style: solid;
border-top-color: rgba(255, 255, 255, 0.5);
border-left-color: rgba(0, 0, 0, 0.3);
border-right-color: rgba(0, 0, 0, 0.3);
border-bottom-color: rgba(0, 0, 0, 0.8);
}
.box.box2 {
background: red;
}
<button class="box box2" type="button"></button>
<button class="box " type="button"></button>
<div class="box"></div>
Give them both a display:block (or inline-block) and add box-sizing:content-box to both, then add box-sizing to both (border-box)
As for a FULL answer: this has to do with the border-box and content box which differs from div to button
Button uses the smaller and div the larger.
content-box uses the size + padding + borders
border-box uses size + padding - borders
SO your 4px X 2 border-radius has to be added TO the button to make it the same size as the div.
Here I show both the fixed and then the original for comparison (all as inline-block just for visual) Notice the first group is the same size as the second groups DIV.
Hopefully this gives a better explanation and how to "fix" it.
body {
font-size: 16px;
background-color: #ddffdd;
margin: 0;
padding: 0;
}
button.exit,
div.exit,
div.exit-new,
button.exit-new {
display: inline-block;
position:relative;
}
div.exit-new,
button.exit-new {
width: 47px;
height: 47px;
}
div.exit {
box-sizing: content-box;
width: 47px;
height: 47px;
top: 4px;
}
button.exit {
box-sizing: border-box;
width: 55px;
height: 55px;
}
/*add element just for specificity here */
button.exit,
div.exit,
div.exit-new,
button.exit-new {
background: red;
border-radius: 4px;
border-width: 4px;
border-style: solid;
border-top-color: rgba(255, 255, 255, 0.5);
border-left-color: rgba(0, 0, 0, 0.3);
border-right-color: rgba(0, 0, 0, 0.3);
border-bottom-color: rgba(0, 0, 0, 0.8);
}
.exit.exitPage2 {
background: red;
}
<div class="container">
<button class="exit exitPage2" type="button"></button>
<button class="exit " type="button"></button>
<div class="exit"></div>
</div>
<div class="container">
<div>originals</div>
<button class="exit-new" type="button"></button>
<button class="exit-new" type="button"></button>
<div class="exit-new"></div>
</div>
try editing the buttons in the .exitpage2 css like this
.exit.exitPage2 {
background: red;
width: 50px;
height: 50px;
}
it should do what you need it to if you set the height and width to the desired amounts
I currently have a header div and inside of it, I have header-top and header-bottom. I am trying to place my logo on the top-header and align it vertically and horizontally. The logo aligns horizontally but vertically, it pushes aligns according to the body it seems and it brings the header down 20px. Here is my code.
HTML:
<body>
<div id="big-wrapper">
<div id="header">
<div id="header-top">
<img src="img/main-logo.png" />
</div>
<div id="header-bottom">
</div>
</div>
</div>
</body>
CSS:
#header {
width: 100%;
height: 160px;
box-shadow: 0 1px 4px 1px rgba(237, 237, 237, 1);
}
#header-top {
height: 130px;
border-bottom: 1px solid rgba(200, 200, 200, 0.7);
background-color: rgba(255, 255, 255, 1);
}
#header-top img {
height: 90px;
width: 255px;
display: block;
margin: 20px auto;
}
#header-bottom {
height: 30px;
border-bottom: 1px solid rgba(200, 200, 200, 0.7);
background-color: rgba(255, 255, 255, 1);
}
This is what I get
Suggestion. Could be wrong.
<div id="header-top">
<center>
<img src="img/main-logo.png" />
</center>
</div>
If wrong, try aligning the div as so.
Edit:
If all else fails, edit image, and offset it to desired alignment
I have a button and a container on a single line and I'm trying to get the button to be the full width (btn-block in bootstrap) while the count box is on the same line. The problem right now is I can get the button on the same line, if I give it a fixed width, but that doesn't work if the container is a smaller width on other resolutions or if the button has a count of 4834 instead of 3 for example.
Here is what I have now:
<div class="button-container">
<div class="btn btn-primary">Boo</div>
<div id="count_box" class="count_box">42</div>
</div>
The .count_box has this CSS:
.count_box {
position: relative;
background: #FFF;
border: 1px solid #333;
display: inline-block;
margin-left: 10px;
border-radius: 3px;
padding: 6px 10px;
top: 1px;
color: #333;
}
Note that .button_container can be 600px wide or 200px wide, etc. So I can't give it a fixed width. A jsFiddle explains it better than the code here: http://jsfiddle.net/gdrpmr13/1/
Is there any easy way to do get both the button and the count on the same line and the button being 100% (minus the width of the count)? I'm lost.
You can do it with some smart float manipulations, so that all widths are dynamic and still button fills remaining width. Note, that I added class pull-right to count box and moved it before button.
.button-container .btn {
display: block;
width: auto;
overflow: hidden;
}
.count_box {
position: relative;
background: #FFF;
border: 1px solid #333;
margin-left: 10px;
border-radius: 3px;
padding: 6px 10px;
top: 1px;
color: #333;
}
.count_box:after, .count_box:before {
right: 100%;
top: 50%;
border: medium solid transparent;
content:" ";
height: 0px;
width: 0px;
position: absolute;
pointer-events: none;
}
.count_box:after {
border-color: rgba(255, 255, 255, 0) #FFF rgba(255, 255, 255, 0) rgba(255, 255, 255, 0);
border-width: 8px;
margin-top: -8px;
}
.count_box:before {
border-color: rgba(221, 221, 221, 0) #333 rgba(221, 221, 221, 0) rgba(221, 221, 221, 0);
border-width: 9px;
margin-top: -9px;
}
.button-container {
display: inline-block;
width: 400px;
background-color: #FF0000;
padding:20px 0px;
}
.button-container-2 {
margin-top:20px;
display: inline-block;
width: 200px;
background-color: #FF0000;
padding:20px 0px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css">
<div class="button-container">
<div class="count_box pull-right">42</div>
<div class="btn btn-primary">Boo</div>
</div>
<div class="button-container">
<div class="count_box pull-right">4333234</div>
<div class="btn btn-primary">Boo</div>
</div>
And here is another demo with demonstrates how it would work when parent container is resized (resize demo pane): http://jsfiddle.net/gdrpmr13/3/
You can make the count part of let's say 60px and button of remaining width.
So you should choose this 60px width by assuming the maximum count you're expecting in there and then align it the way you want.
HTML
<div class="button-container">
<div class="btn btn-primary btn-block-almost">Boo</div>
<div id="count_box" class="count_box">42</div>
</div>
<div class="button-container-2">
<div class="btn btn-primary btn-block-almost">Boo</div>
<div id="count_box" class="count_box">4255</div>
</div>
CSS
.count_box {
position: relative;
background: #FFF;
border: 1px solid #333;
display: inline-block;
margin-left: 10px;
border-radius: 3px;
padding: 6px 10px;
top: 1px;
color: #333;
width: 60px;
}
.btn-block-almost{
width: calc(100% - 80px);
}
Just added some css and a class to your markup and this looks fine to me
fiddle: https://jsfiddle.net/arpit_goyal/81npkrdj/
Normally the elements of an HTML markup appear in the order they are written in the markup file, and the inline elements appear from left to right.
But I want the children of a certain div (only, NOT all the elements of the entire page) to appear from right to left.
In case you wonder why it is needed, I want to do this to solve the following problem:
PROBLEM:
JSFiddle here.
.wrapper {
height: 100%;
width: 826px;
margin: 50px auto;
display: table;
background-color: #003b80;
}
.cell {
display: table-cell;
vertical-align: top;
}
.left-cell {
width: 50%;
background-color: chocolate;
}
.right-cell {
background-color: darkslategrey
}
.step-container {
max-height: 200px;
font-size: 0;
}
.right-cell .step-container {
margin-top: 125px;
}
.content-box {
display: inline-block;
width: 350px;
height: 200px;
/*border: 5px solid blue;*/
font-size: 0;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.69);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.69);
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.69);
background-color: dodgerblue
}
.right-cell .content-box {
background-color: darkturquoise
}
.middle-cell {
height: 100%;
background-color: white;
width: 1.5px;
font-size: 0;
box-shadow: 0px 0px 10px black;
-moz-box-shadow: 0px 0px 10px black;
-webkit-box-shadow: 0px 0px 10px black;
}
.number-outer-container {
display: inline-block;
position: absolute;
}
.left-cell .number-outer-container {
/*margin-left:39px;*/
}
.number-inner-container {
height: 200px;
display: flex;
flex-direction: column;
justify-content: center;
}
.number-banner {
width: 50px;
height: 50px;
background-color: crimson;
-moz-border-radius: 25px;
-webkit-border-radius: 25px;
border-radius: 25px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
}
.notch-outer-container {
display: inline-block;
}
.left-cell .notch-outer-container {
margin-right: 24px;
}
.right-cell .notch-outer-container {
margin-left: 10px;
}
.notch-inner-container {
height: 200px;
display: flex;
flex-direction: column;
justify-content: center;
}
.notch {
width: 0;
height: 0;
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
}
.left-face-notch {
border-right: 15px solid #520f23;
}
.right-face-notch {
border-left: 15px solid #571780;
}
<div class="wrapper">
<div class="cell left-cell" align="left">
<div class="step-container">
<div class="content-box"></div>
<div class="notch-outer-container">
<div class="notch-inner-container">
<div class="right-face-notch notch"></div>
</div>
</div>
<div class="number-outer-container">
<div class="number-inner-container">
<div class="number-banner"></div>
</div>
</div>
</div>
</div>
<div class="cell middle-cell"></div>
<div class="cell right-cell" align="right">
<div class="step-container">
<div class="number-outer-container">
<div class="number-inner-container">
<div class="number-banner"></div>
</div>
</div>
<div class="notch-outer-container">
<div class="notch-inner-container">
<div class="left-face-notch notch"></div>
</div>
</div>
<div class="content-box"></div>
</div>
</div>
</div>
In this SSCCE, inside .left-cell .step-container, I have three elements appearing on the same line: .content-box, .notch-outer-container, and .number-outer-container; and to make the .notch appear to be overlapping the right-cell by 50% of its width, I gave .number-outer-container a position:absolute; and .notch-outer-container a margin-right which pushes the number-outer-container to right side to an extent that it appears to be overlapping the (.middle-cell and) right-cell by 50% of it's width.
The problem is that in the .right-cell, this strategy is NOT working. First the .number-right-container appears and still it is absolute, I can not give it a left property with value relative to its parent (otherwise I would try a left:-25px to make it appear 25px behind the left edge of its parent, because it has width:50px;). Then the .notch is hidden below it...
So I am thinking about finding a way through which I can get the elements render from RTL (Right To Left) rather than LTR only inside .right-cell on the page. So that I can follow the same strategy I have used for the .left-cell, in the .right-cell.
There's numerous ways to achieve what you want using either flexing, floats or other options, but I'd say one of the easiest ways, if the rest of the layout works as you want it to, is to use the direction attribute.
div {
direction: rtl;
}
div div {
display: inline-block;
direction: ltr;
}
<div>
<div>first</div>
<div>second</div>
<div>last</div>
</div>
I have a pretty simple div structure - tree boxes with middle box highlighted with box-shadow:
.offerBox {
width: 300px;
margin: 10px;
}
.obOffer {
width: 33%;
float: left;
height: 100px;
text-align: center;
}
.obOfferPrice {
padding: 10px;
color: white;
background-color: #85AADD;
}
.obHiLight {
box-shadow: 0 0 25px rgba(0, 0, 0, 0.6);
-moz-box-shadow: 0 0 25px rgba(0, 0, 0, 0.6);
-webkit-box-shadow: 0 0 25px rgba(0, 0, 0, 0.6);
}
<div class="offerBox">
<div class="obOffer">
<div class="obOfferTitle">Free</div>
<div class="obOfferPrice">Free</div>
</div>
<div class="obOffer obHiLight">
<div class="obOfferTitle">Title</div>
<div class="obOfferPrice">$10</div>
</div>
<div class="obOffer">
<div class="obOfferTitle">Title 2</div>
<div class="obOfferPrice">$10</div>
</div>
</div>
One of the elements inside those boxes have a background-color property set. For some reasons this background-color removes the box-shadow from the right and only from the right.
Any ideas why and how to fix it?
Live Example of the problem:
http://jsfiddle.net/SqvUd/
You just need to add z-index and position:relative;
See the example:
.offerBox {
border-radius: 6px;
width: 300px;
margin: 10px;
}
.obOffer {
position: relative; // 👈 this
width: 33%;
float: left;
height: 100px;
text-align: center;
z-index: 0;
}
.obOfferPrice {
padding: 10px;
color: white;
background-color: #85AADD;
}
.obHiLight {
z-index: 10;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.6);
}
<div class="offerBox">
<div class="obOffer">
<div class="obOfferTitle">Free</div>
<div class="obOfferPrice">Free</div>
</div>
<div class="obOffer obHiLight">
<div class="obOfferTitle">Title</div>
<div class="obOfferPrice">$10</div>
</div>
<div class="obOffer">
<div class="obOfferTitle">Title 2</div>
<div class="obOfferPrice">$10</div>
</div>
</div>
It has to do with the z-index of the items. Try adding this to your existing css:
.obOffer {
position: relative;
z-index: 10;
}
.obHiLight {
position:relative;
z-index: 100;
}
adding .obHiLight{opacity:0.999} creates a new stacking context for that element, which makes it appear above the others as well. This might work for tables too (didn't test :) . #ItJustWerks #brian-tacker