Hexagon with 90deg rotate does not grow inside container - html

I have the following problem with my hexagons. With the code below it works fine and the hexagon stays within its container.
.hexagon-2 .content {
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
padding: 30px;
text-align: center;
}
.wrapper {
width: 100%;
/* This is the only value you need to change */
}
.container-2 {
position: relative;
width: 100%;
padding-bottom: 86.6%;
/* This sets the height of the div to 86% of its width */
border: 1px dashed green;
/* Just for demonstration purposes*/
transform: rotate(90deg);
}
.hexagon-2 {
position: absolute;
/* so .hexagon isn't pushed out of .container by the padding */
left: 25%;
width: 50%;
height: 100%;
margin: 0 auto;
/* center .hexagon inside .container*/
background-color: red;
/* color of the hexagon */
}
.hexagon-2:before,
.hexagon-2:after {
display: block;
position: absolute;
/* otherwise :after is below the hexagon */
top: 0;
content: '';
width: 100%;
height: 100%;
background-color: inherit;
}
.hexagon-2:before {
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
-ms-transform: rotate(60deg);
transform: rotate(60deg);
}
.hexagon-2:after {
-webkit-transform: rotate(120deg);
-moz-transform: rotate(120deg);
-ms-transform: rotate(120deg);
transform: rotate(120deg);
}
<div class="container">
<div class="row">
<div class="col-lg-6">
<div class="wrapper">
<div class="container-2">
<div class="hexagon-2">
<span class="content">Test test test</span>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="wrapper">
<div class="container-2">
<div class="hexagon-2">
<span class="content">Test test test</span>
</div>
</div>
</div>
</div>
</div>
</div>
As long as I leave the hexagon that way, it works exactly as it should. However, when I rotate the hexagon 90 degrees, it goes wrong.
When I add this line to the .container-2 class:
transform: rotate(90deg);
The hexagons behave like this:
Because of the rotate they no longer fill out the container. Is there a clean way to solve this. I have already tried everything with these hexagons but no luck so far.
Anybody got an idea that I can stil rotate the hexagon but that it stil fills out the container?
Thanks

Just off the top of my head looking at this the reason it's not filling out the container is because the width of the hexagon is different. If you want it to fill exactly the same size when it is rotating make sure point to point is the same width as flat edge to flat edge. I did a quick check and point to point is 310 pixels and flat edge to flat edge is 263 pixels. Hope this helps.

Related

Flex images and positioning issue

What I'm trying to achieve, once I reduce the size of the screen and some elements starts to move to a second line, keep them organized to the left, instead of centered (based on the number of elements on that row). This image might help
And this is my actual code, what I'm doing wrong?
#teamBoxesWrapper {
position: relative;
background-color: ;
width: 1200px;
height: auto;
left: 50%;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
-moz-transform: translateX(-50%);
-ms-transform: translateX(-50%);
-o-transform: translateX(-50%);
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
#teamUser {
width: 250px;
/* 20% of the viewport width */
height: 250px;
background-color: ;
margin: auto;
cursor: pointer;
margin-bottom: 20px;
position: relative;
}
.teamUser4 {
background-image: url('../images/empleado4.jpg');
background-position: center center;
background-size: cover;
}
<div id="teamBoxesWrapper">
<div id="teamUser" class="teamUser4">
<div id="teamUserPopup4" class="teamUserDetails">
<div id="teamUserTextAligner">
<h3 class="teamUserText1">Manuel Brenes</h3>
<hr class="userHr" />
<h3 class="teamUserText2">Graduado Social y
<br>Derechos Laborales</h3>
</div>
</div>
</div>
</div>
On your code try replacing your justify-content: space-between for center;

rotateY or rotateX just make my picture smaller when they rotate it

I have a product div and whenever I hover over it, it rotated and shows the other side, it works and all but the thing is it becomes smaller, here's an idea of what it looks like here.
.product {
transform: scale(1.5);
transition: transform 1s cubic-bezier(.1, -.60, .50, 1.2);
perspective: 700px;
transform-style: preserve-3d;
}
.inner img {
height: 65px;
width: 65px;
}
.product:hover {
transform: rotateY(-180deg);
}
.product:hover .side-b {
transform: rotateY(180deg);
display: block;
}
.product:hover .side-a {
visibility: hidden;
}
.product-desc {
color: #fff;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding-left: 20px;
padding-right: 20px;
display: flex;
/* For centering text inside .photo-overlay */
flex-direction: column;
justify-content: center;
align-items: center;
display: none;
line-height: 0;
}
<li>
<div class="product">
<div style="height: 7px;visibility: hidden;"></div>
<div class="inner">
<img class="side-a" src="../images/test.jpg" alt="International Space Station">
<div class="product-desc side-b">
<h3>hi</h3>
buy
</div>
</div>
</div>
</li>
The resizing is because of your first rule transform: scale(1.5);. It tells the browser to initially resize the .product element to 50% more than its original size. But than on hover, you overwrite your transform- rule by only a rotation statement. Either delete this first rule or also use it in your :hover definition:
.product:hover {
transform: scale(1.5) rotateY(-180deg);
}
The transform: scale(1.5); created the problem!
Thanks to #Mohd Asim Suhail for pointing it out!
transform: scale(1.5); is creating problem for you, – Mohd Asim Suhail 3 mins ago

Blurred portion over image, solid edges, responsive images

I'm trying to replicate the following blur effect with pure HTML/CSS. My current appraoch uses 2 images, the original cover-image, then, a 2nd copy of the image blurred-bg-image using CSS filter: blur(5px);.
Desired effect:
source
I can't find any way to keep the bottom portion the height of the toolbar while also retaining a background-image equal to the dimensions of the entire cover-image.
overflow: hidden doesn't work on a child element when the parent is anything but position: relative. But if the parent is relative, the inner blurred-bg-image is not the same dimensions as the cover-image
Here is the basic setup:
<div class="cover-image">
<div class="toolbar">
<div class="blurred-bg-image"></div>
</div>
</div>
The only solution I can find so far is to use clip rect() on blurred-bg-image, then calculate where to clip it to. But, this is not responsive and includes JS into the mix.
Here is a CodePen by the OP showing the end result.
The Method
You can use the method described here on CSS Tricks.
This method utilizes the following:
absolute positioning
transforms
one image for the background and blur effect
You'll have to adjust things with media queries, but that's not difficult. The only main drawback I see is that you have to set a fixed height on the toolbar content, because that height is used in the transforms. But again, that's easily done with media queries.
See the following snippet for the source and demo. I put some comments in the CSS.
html,
body {
width: 100%;
height: 100%;
}
.cover-image {
position: relative;
max-width: 1860px;
width: 100%;
max-height: 560px;
height: 100%;
overflow: hidden;
background-color: #005FE5;
}
.toolbar {
position: absolute; /* put .toolbar at the bottom of .cover-image */
bottom: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
overflow: hidden; /* keep pseduo-element from breaking out */
-webkit-transform: translateY(100%) translateY(-10rem); /* translate down all the way, then back up by height of .toolbar-content */
-moz-transform: translateY(100%) translateY(-10rem);
-ms-transform: translateY(100%) translateY(-10rem);
-o-transform: translateY(100%) translateY(-10rem);
transform: translateY(100%) translateY(-10rem);
}
/* the background will be the same for both elements but we will blur the pseudo-element later */
.cover-image,
.toolbar::before {
background-image: url("https://dl.dropboxusercontent.com/s/3vzuc6vmfito1zg/austin-cityscape-night-hdr-1.jpg?dl=0");
background-repeat: no-repeat;
background-position: center bottom;
background-size: cover; /* scales the background accordingly */
}
/* use this pseudo-element for the blur effect */
.toolbar::before {
content: "";
position: absolute;
bottom: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
-webkit-transform: translateY(-100%) translateY(10rem); /* translate inversely to what we translated .toolbar */
-moz-transform: translateY(-100%) translateY(10rem);
-ms-transform: translateY(-100%) translateY(10rem);
-o-transform: translateY(-100%) translateY(10rem);
transform: translateY(-100%) translateY(10rem);
-webkit-filter: blur(10px); /* finally! the blur effect */
filter: blur(10px);
}
.toolbar-content {
position: relative;
height: 10rem; /* use this value in the transforms */
color: #FFF;
}
.toolbar-content ul {
position: absolute;
top: 50%;
left: 5%;
margin: 0;
padding: 0;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
list-style: none;
}
.toolbar-title {
color: #A6BFC9;
text-transform: uppercase;
}
.edit-profile {
position: absolute;
top: 50%;
right: 5%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
-webkit-appearance: none;
background-color: #00A9F3;
border: none;
}
#media only screen and (max-width: 66.25rem) {
.toolbar-content ul li {
margin-bottom: 0.25rem;
}
.toolbar-title,
.toolbar-detail {
display: inline-block;
}
.toolbar-title::after {
content: ":";
}
}
#media only screen and (min-width: 66.3125em) {
.toolbar {
-webkit-transform: translateY(100%) translateY(-6.25rem);
-moz-transform: translateY(100%) translateY(-6.25rem);
-ms-transform: translateY(100%) translateY(-6.25rem);
-o-transform: translateY(100%) translateY(-6.25rem);
transform: translateY(100%) translateY(-6.25rem);
}
.toolbar::before {
-webkit-transform: translateY(-100%) translateY(6.25rem);
-moz-transform: translateY(-100%) translateY(6.25rem);
-ms-transform: translateY(-100%) translateY(6.25rem);
-o-transform: translateY(-100%) translateY(6.25rem);
transform: translateY(-100%) translateY(6.25rem);
}
.toolbar-content {
height: 6.25rem;
}
.toolbar-content ul li {
display: inline-block;
padding: 0.625rem 1.25rem;
text-align: center;
}
}
<div class="cover-image">
<div class="toolbar">
<div class="toolbar-content">
<ul>
<li>
<div class="toolbar-title">Edad</div>
<div class="toolbar-detail">20 años</div>
</li>
<li>
<div class="toolbar-title">Cumpleaños</div>
<div class="toolbar-detail">8 de septiembre de 1994</div>
</li>
<li>
<div class="toolbar-title">Primera Conexión</div>
<div class="toolbar-detail">14 de enero de 2009</div>
</li>
<li>
<div class="toolbar-title">Klout</div>
<div class="toolbar-detail">87</div>
</li>
<li>
<div class="toolbar-title">Twitter</div>
<div class="toolbar-detail">1.806</div>
</li>
<li>
<div class="toolbar-title">Facebook</div>
<div class="toolbar-detail">345</div>
</li>
</ul>
<button class="edit-profile" type="button">Editar perfil</button>
</div>
</div>
</div>
<div class="some-other-content">
<p>You can add more content here</p>
<p>You can add more content here</p>
<p>You can add more content here</p>
<p>You can add more content here</p>
<p>You can add more content here</p>
<p>You can add more content here</p>
<p>You can add more content here</p>
<p>You can add more content here</p>
<p>You can add more content here</p>
</div>
Hacked away at this for a while today. Here is what I got:
glass.html
<html><head><link rel="stylesheet" type="text/css" href="glass.css"/></head>
<body>
<div id="bkgrd">
<div class="blur-bkgrd-position cropper flip ">
<div class="blur-bkgrd-position glass flip">
</div>
</div>
</div>
</body>
glass.css
#bkgrd{
position:absolute; /*align very top left */
top:0; /*align very top left */
left:0; /*align very top left */
width: 100%; /* full screen for background cover/contain */
padding-top: 56.25%; /* helps "bkgrd-size contain" stretch to full width by breaking height limit */
/*image*/
background-image: url(yourbackground.jpg);
background-size: contain; /*responsive width-wise, no js */
background-repeat: no-repeat;
overflow: hidden;
}
.blur-bkgrd-position {
position:absolute;
top:50%; /*sets up cut off point*/
left:0; /*align very left */
width: 100%; /* full screen for background cover/contain */
padding-top: 56.25%; /* helps "bkgrd-size contain" stretch to full width by breaking height limit */
}
.glass {
/*blurred image*/
background:
/* dark blue */
linear-gradient(
rgba(0, 0, 30, 0.45),
rgba(0, 0, 30, 0.45)
),
url(yourbackground.jpg);
background-size: contain; /*responsive width-wise, no js */
background-repeat: no-repeat;
background-position: center bottom.
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}
.cropper {
overflow: hidden; /* performs the cropping */
}
/* apply to both .cropper and .glass */ /* enables crop from the top */
.flip {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
Basically, we got two identical background images except one has a tint and blur effect, and is wrapped by an upside-down cropper.
Codepen: http://codepen.io/vtange/pen/MajweX
Helpful link: https://css-tricks.com/crop-top/
I've added the background image to the toolbar using ::before, which is positioned at the top of the toolbar. The image area and the pseudo element height should use a root based units, such as vh or rem, so they will be the same size regardless of their container size. In addition, the pseudo element background settings are identical to those of the main background. The pseudo element is blurred, and excess background is removed using the toolbar's overflow: hidden.
Resize the results panel in this Fiddle demo.
html, body {
margin: 0;
padding: 0;
}
.top-image {
position: relative;
min-height: 100px;
}
.top-image, .toolbar::before {
height: 50vh; /** the image and the blurred area height **/
background: url('http://www.theplanningboardroom.net/wp-content/uploads/2011/06/sydney-city-buildings.jpg') no-repeat;
background-size: cover;
}
/** the .toolbar::before is position at the bottom of the toolbar, so excess height goes up **/
.toolbar, .toolbar::before {
position: absolute;
right: 0;
bottom: 0;
left: 0;
}
.toolbar {
z-index: 1;
/** height can also be percentage such as 20% **/
height: 100px;
/** hide the rest of the background ::before **/
overflow: hidden;
/** some styling for the text and controls **/
box-sizing: border-box;
padding: 10px;
text-align: center;
}
.toolbar::before {
z-index: -1;
display: block;
/** the height is full screen height **/
-webkit-filter: blur(5px);
filter: blur(5px);
content:'';
}
<div class="main">
<div class="top-image">
<div class="toolbar">
text and controls
</div>
</div>
<div>
<p>The content</p>
</div>
</div>
If you don't wish the toolbar to be on the edge of the image, you can position it anywhere you wish inside it. Just set the toolbar's left, right, and bottom, and .toolbar::before properties the negative value (demo):
.toolbar {
position: absolute;
right: 100px;
bottom: 50px;
left: 100px;
}
.toolbar::before {
position: absolute;
right: -100px;
bottom: -50px;
left: -100px;
}
I don't know why you're getting problem in doing this, I was able to do it by using another div extending it fully wide and height equal to the toolbar and then set the same background-image and then blurred it.
Here is the code-
html,
body {
margin: 0;
padding: 0;
}
#container {
width: 100%;
background: black url('http://tinyurl.com/pgfnxag') bottom center no-repeat;
background-size: 100% auto;
position: relative;
overflow: hidden;
color: white;
font-size: 30px;
text-align: center;
}
#glass {
background-color: rgba(255, 255, 255, 0.25);
padding: 35px 0;
width: 100%;
color: white;
position: absolute;
bottom: 0;
border-top: 1px solid rgba(255, 255, 255, 0.2);
}
#blurred {
position: absolute;
width: 100%;
background: url('http://tinyurl.com/pgfnxag') bottom center no-repeat;
background-size: 100% auto;
filter: blur(5px);
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
top: 0;
left: 0;
height: 100%;
}
#content {
z-index: 999;
display: block;
position: absolute;
top: 50%;
left: 50%;
font-size: 20px;
font-weight: 100;
transform: translate(-50%, -50%);
font-family: Segoe UI;
text-align: center;
}
<div id="container">This is content above blurred part... Lorem ipsum dolor sit amet... and after that so more contents can go here..
<br />
<br />
<br />
<br />
<br />
<br />
<div id="glass">
<div id="blurred"></div>
<div id="content">Here goes the content..</div>
</div>
</div>
Fiddle demo to play with height of #glass and edit contents present in #content, the #blurred is the div holding the same background-image. The real trick here was to set all background properties (background-size, background-position, etc) exactly same as the #container.
UPDATE: changed to background-size: 100% auto;, now works well for any height or width of container or viewport.
EDIT: Removed all height properties, now its fully responsive! Run Code Snippet above.
Backdrop filters can do this, but are currently working only in Safari with the -webkit- prefix (and Chrome if you enable "Experimental Web Platform Features").
.toolbar{
-webkit-backdrop-filter: blur(5px);
backdrop-filter: blur(5px);
}
More info here.
body {
background: url(https://farm2.staticflickr.com/1551/25178575880_1449360954_k_d.jpg);
background-size: cover;
padding: 0;
margin: 0;
}
.box {
border-bottom: 1px solid rgba(0, 0, 0, 0.5);
-webkit-backdrop-filter: blur(6px);
backdrop-filter: blur(6px);
padding: 10px;
color: #fff;
font: 24px Arial, sans-serif;
background: rgba(255, 255, 255, 0.25);
}
<div class="box">
test box
</div>

Align rotated div with another div

I have a main div (the red div in the fiddle) that has a smaller vertical tab on the side (the blue div in the fiddle).
The RED div is standard BUT the Blue div is rotated through 90 degrees (as I need to have vertical text in it). This is where the problems starts.
The red div is vertically positioned at 50% so it is in the middle of the page and locked with scrolling etc.
I want to align the blue div so that the top edge of the blue div is at the same Y position as the top edge of the red div.
I would prefer NOT to use jQuery but can do if required.
Desired output :
Fiddle is here : http://jsfiddle.net/kBKf6/
Here is the code I am using :
<div id="main" style="position: fixed; top: 50%; margin-top: -250px; left:0; height: 500px; width: 450px; background-color:red;">
Main Content Div
</div>
<div id="vertical_div" style="overflow:hidden; position: fixed; left:350px; height:40px; width:200px; margin: auto; background-color:blue; text-align:center; color:white; -webkit-transform: rotate(90deg) translate(-50%, -50%); -moz-transform: rotate(90deg) translate(-50%, -50%); -ms-transform: rotate(90deg) translate(-50%, -50%); -o-transform: rotate(90deg) translate(-50%, -50%); transform: rotate(90deg) translate(-50%, -50%);">
Side Tab
</div>
You don't need JS to align the rotated div. You can define a transform origin in CSS then, it becomes easy to align.
Side note : You can remove the -moz- and -o- vendor prefixes see caniuse
DEMO
HTML :
<div id="main">Main Content Div
<div id="verticaldiv">Side Tab</div>
</div>
CSS :
#main {
position: fixed;
top: 50%;
margin-top: -250px;
left:0;
height: 500px;
width: 450px;
background-color:red;
}
#verticaldiv {
overflow:hidden;
position: absolute;
left:100%;
bottom:100%;
height:40px;
width:200px;
background-color:blue;
text-align:center;
color:white;
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
-ms-transform-origin:0 100%;
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
}
You can also do it without relying on hardcoded sizes that move your div into position, but you need a wrapper around your .verticaldiv
demo:
http://jsfiddle.net/MCr6f/
demo 2:
http://jsfiddle.net/9LtKw/ (to show that different sizes don't matter)
html:
<div class="one">
Hello
<div class="pivot">
<div class="two">
Pretty!
</div>
</div>
</div>
css:
.one {
background: red;
position: relative;
float: left;
/*strange and difficult sizes*/
font-size: 3.237827em;
padding: 10px;
}
.pivot {
position: absolute;
top: 0;
right: 0;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
transform: rotate(90deg);
width: 0px;
height: 0px;
}
.two {
background: blue;
color: white;
position: absolute;
left: 0;
bottom: 0;
/*strange and difficult sizes*/
font-size: 12px;
padding: 0.3em;
}

Vertical menu with rotated text at 100% height

I've followed this How to make vertically rotated links in HTML? but I've to improve this solution.
I need to have a vertical menu that fits the entire height of the windows and divides it in three part (cause I've three menu links to show).
How can I update the code suggested in that solution?
Try this:
CSS
#container {
overflow: hidden;
width: 50px;
height: 100%;
position: absolute;
top: 0;
left: 0;
display: table;
}
.section {
position: relative;
height: 33.33333%;
display: table-row;
background: #ccc;
text-align: center;
}
.section .link {
display: table-cell;
vertical-align: middle;
line-height: 50px;
white-space:nowrap;
max-width:50px;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
}
.section:hover { background: #ddd }
HTML
<div id="container">
<div class="section">aaa</div>
<div class="section">bbb</div>
<div class="section">ccc</div>
</div>
DEMO JSFiddle
My suggestion is to use display: table CSS property as follow:
EDITED
HTML
<div class="container">
<div class="container-child">row 1</div>
<div class="container-child">row 2</div>
<div class="container-child">row 3</div>
</div>
CSS
html, body {
text-align: center;
width: 100%;
height: 100%;
}
.container {
display: table;
width: 100%;
height: 100%;
}
.container-child {
display: table-row;
-ms-transform:rotate(270deg); /* IE 9 */
-moz-transform:rotate(270deg); /* Firefox */
-webkit-transform:rotate(270deg); /* Safari and Chrome */
-o-transform:rotate(270deg); /* Opera */
}
CODE
the transform: rotate() allows you to rotate the orientation of the text.