Alternative to vertical alignment with table and table-cell - html

I have this pen: http://codepen.io/helloworld/pen/VYWGbz
I have set these classes in my production code and they cause IE 11 to NOT render somehow the left black border WHEN the drawer is opened.
When I remove the vertical-alignment with table/table-cell as display property the error disappears... (In Chrome its fine...)
What choice do I have else to vertically align the drawer`s glyphicon/span instead of using table on parent and table-cell on child to make vertical align possible with middle?
Note: The drawer/sidebar always have a height of 100% recieved by its parent.
.drawer-left-trigger{
display:table;
}
.drawer-left-trigger > span{
display:table-cell;
vertical-align:middle;
}
HTML
<div id="idtView">
<div style="height:100%;background:blue;" class="col-xs-3">
test1
</div>
<div style="height:100%;background:yellow;" class="col-xs-4">
test2
</div>
<div id="availableSidebarColumn" style="background:orange;padding:0;height:100%;" class="col-xs-1">
<div class="drawer-wrapper">
<div id='drawer-left' class='closed'>
<div class='drawer-left-trigger'>
<span class='glyphicon glyphicon-chevron-left'></span>
</div>
<div class='drawer-left-content'>
<div style="background:orange;;" id="availableCommandsPagerNavigation">
<span class="previous disabled glyphicon glyphicon-chevron-left availableOptionsArrow availableOptionsPagerArrow"></span>
<span class="glyphicon glyphicon-chevron-right availableOptionsArrow availableOptionsPagerArrow"></span>
</div>
<div style="background:gray;" id="availableCommandsContainer">
contentcontentcontentcontentcontentcontentcontent contentcontent content
</div>
</div>
</div>
</div>
</div>
<div style="height:100%;background:pink;" class="col-xs-4">
test2
</div>
</div>
CSS
/*new stuff*/
*{
box-sizing: border-box;
}
.drawer-wrapper{
margin: 0 200px;
display: inline-block;
}
/*The left drawer*/
#drawer-left{/*set a container with the total width of both the container and the trigger*/
position: relative;
height: 100%; width: 205px;
overflow: hidden;
transition: all .35s ease-in-out;
}
#drawer-left:after{/*this will the right border, when the content will be pushed out*/
content: '';
position: absolute;
right: 0; top: 0; bottom: 0;
border-right: 1px solid #000;
}
.drawer-left-trigger{
/*set the triggers width here, borders etc.*/
position: absolute;
top: 0; bottom: 0; right: 100%;
margin-right: -25px;/*bring it back inside the wrapper*/
width: 25px;
background:yellow;
/*some styling stuff*/
cursor: pointer;
text-align: center;
font-size: 24px;
line-height: 100%;
}
.drawer-left-trigger > span{
transform: rotate(180deg);
transition: all .35s ease-in-out;
}
#drawer-left.closed .drawer-left-trigger > span{
transform: rotate(0);
}
#drawer-left.closed .drawer-left-trigger{
/*this will push the trigger on the right side*/
left: auto;
right: 25px;
}
.drawer-left-content{
/*this is the container for the header and content*/
position: absolute;
top: 0; bottom: 0; right: 0; left: 24px;/*the triggers width(+-1px from the border)*/
}
#drawer-left.closed .drawer-left-content{
/*this will push the content out*/
left: 100%;
right: -100%;
}
.drawer-left-trigger,
.drawer-left-content{
border-left: 1px solid #000;
border-bottom: 1px solid #000;
border-top: 1px solid #000;
transition: all .35s ease-in-out;
}
JS
$(function () {
/*the left one*/
$('.drawer-left-trigger').click(function(){
$(this).parent().toggleClass('opened closed');
});
});

You could use FlexBox.
http://css-tricks.com/snippets/css/a-guide-to-flexbox/
Browser Support
http://caniuse.com/#feat=flexbox

You can use translateY, and position relative.
.drawer-left-trigger > span{
transition: all .35s ease-in-out;
transform: rotate(180deg) translateY(-50%);
position: relative;
top: 50%;
}
If the .drawer-wrapper is the only element on the page, consider setting its height to 100% instead of 500px by adding
html,body,.drawer-wrapper {
height: 100%;
}
If you need to add some navigation bar on top, calculate drawer's height by calc(100% - 50px) where 50px is the height of navigation bar.
Working version
http://codepen.io/antraxis/pen/yyoNpg

Related

In what manner, rotation is 90 degrees here?

In the code below, the button with close id, is rotated 90 degrees. But I don't get how that button moved 90 degrees and with respect to what origin. transform-origin: top left; But top left of what element?
body {
margin: 0;
}
.circle-container {
position: fixed;
top: 100px;
left: 100px;
}
.circle {
background-color: #ff7979;
height: 200px;
width: 200px;
/* border-radius: 50%; */
position: relative;
transition: transform 0.5s linear;
}
.circle button {
position: absolute;
top: 50%;
left: 50%;
height: 100px;
background: transparent;
border: 0;
font-size: 26px;
color: #fff;
}
.circle button:focus {
outline: none;
}
.circle button#open {
left: 60%;
}
.circle button#close {
top: 60%;
transform: rotate(90deg);
transform-origin: top left;
}
<script src="https://kit.fontawesome.com/e057ae8bc6.js"></script>
<div class="circle-container">
<div class="circle">
<button id="close">
<i class="fas fa-times"></i>
</button>
<button id="open">
<i class="fas fa-bars"></i>
</button>
</div>
Ok, I got it. The top-left is of that button's top-left. I button has been stretched vertically by using height property as well as pushed from the top using absolute positioning. I got confused because, in my mind, I was viewing button element as having an equal size of icon element inside.

Exclude an div element from background overlay

Im trying to make a block with overlay hover effect (default: weak black background color - Hover: none black background) and an icon and text in the middle that stays in the same state all the way.
How do i get the icon and text to stay in the same state (no hover effect)?
Ive tried several rules to the overlay div and the icon div without any luck.
Is there any css rule that provide some kind of exclusion?
I managed to get it to work by adding them outside the divs that has overlay background, but it didnt work out well as the hover effect breaks when you hover over the icon and text.
Here is the code: https://www.w3schools.com/code/tryit.asp?filename=FEMUM4N9T30Q
<style>
.media-front-top-picture{
background-image: url("");
height:500px;
}
.media-front-top-icon{
content: url(");
width: 130px;
margin: auto;
padding-top: 200px;
opacity: 1;
}
.media-front-txt{
font-size: 22px;
letter-spacing: 8px;
color: white;
margin-top: 15px;
}
.media-front-bottom-picture{
background-image: url("h");
height:500px;
}
.media-front-bottom-icon{
content: url("");
width:130px;
margin: auto;
padding-top: 200px;
}
.media-picture-container {
position: relative;
}
.media-picture-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
transition: .5s ease;
background-color: rgba(0, 0, 0, 0.47);
}
.media-picture-overlay:hover {
opacity: 0;
cursor:pointer;
}
</style>
<div class="body-media">
<div class="media-picture-container">
<div class="media-front-top-picture" style="border-bottom:4px solid white;">
<div class="media-front-top-icon"></div>
<div class="media-front-txt">VIDEOS</div>
<div class="media-picture-overlay"></div>
</div>
</div>
<div class="media-picture-container">
<div class="media-front-bottom-picture" style="border-bottom:4px solid white;">
<div class="media-front-bottom-icon"></div>
<div class="media-front-txt">PICTURES</div>
<div class="media-picture-overlay"></div>
</div>
</div>
</div>
for the classes on your icons, add a z-index higher than a z-index you add to the overlay class. Also, make sure to make the icon classes have position:relative so the z-index is applied. Note, my example only applies this solution to one icon, its up to you to apply it elsewhere.
Example:
.media-front-top-icon{
content: url("example.com");
width: 130px;
margin: auto;
padding-top: 200px;
opacity: 1;
z-index:10;
position:relative;
}
.media-picture-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
transition: .5s ease;
background-color: rgba(0, 0, 0, 0.47);
z-index:5;
}

How to place an object next to another, and horizontally center and right-align it?

What is happening
What I want to happen
I want the icon-x-circle to be horizontally centered and on the same line as "Rename" but be right-aligned (probably 30px away from the right end of the header). If someone could let me know how to do that it would be greatly appreciated!
Something to note:
The icon-x-circle itself is not centered. For some reason Fontastic icons seem to add extra space at the bottom. So this is another reason why I'm struggling to horizontally center icon-x-circle.
My Code
HTML
<div id="popup-rename" class="overlay">
<div class="popup">
<header>
<h1>Rename</h1>
<a class="close icon-x-circle" href="#"></a>
</header>
<div class="content">
<div class="student-name student-rect">
<h1>Student Name</h1>
</div>
<div class="save-button center-children">
<a class="save icon-check-circle" href="#"></a>
</div>
</div>
</div>
</div>
CSS
header{
background-color: #F5F5F5;
padding-top: 15px;
padding-bottom: 15px;
text-align: center;
text-transform: uppercase;
}
header h1 {
margin-top: 10px;
margin-bottom: 10px;
font-weight: 300; /*100, 200*/
}
.icon-x-circle{
color: #E1E1E1;
}
.overlay {
position: absolute;
z-index: 2;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
background: white;
width: 50%;
position: relative;
transition: all 200ms ease-in-out;
}
.popup header{
padding: 20px;
}
.close, .save{
transition: all 200ms;
}
.icon-x-circle:hover {
color: #B6B6B6;
}
JSFiddle
One method for aligning elements is to use position: absolute;:
.icon-x-circle {
position: absolute;
right: 0px;
width: 300px;
border: 3px solid #73AD21;
padding: 10px;
}
You can use absolute positioning and put the button wherever you want.
first, make header a relative container
header{
position: relative;
}
Then you can make the button absolute
header a{
position: absolute;
right: 30px;
top: 10px
}
You can mess with right and top to move the button wherever.
https://jsfiddle.net/49abesy2/1/

Transition centered text to left / right edges without overflowing

I was able to transition text-align from center to left. With this code, if you run it, then hover over, you'll see the top one goes to the left. However the bottom overflows on the right; how can I figure out how to make the transition to right not overflow?
Note: This is a demo of my real application, which has strings/elements of unknown/variable width, from 1 to anything to fill a single line (no wrapping).
.header {
position: fixed;
width: 70%;
background-color: springgreen;
}
.title {
text-align: center;
}
.menu {
text-align: center;
}
.trans-left {
transition: margin-right 1s;
}
.trans-right {
transition: margin-left 1s;
}
.header:hover .trans-left {
margin-right: 100%;
}
.header:hover .trans-right {
margin-left: 100%;
}
<body>
<div class='header'>
<div class='title'>
<span class='trans-left'>This one goes left</span>
</div>
<div class='menu'>
<span class='trans-right'>This one goes right</span>
</div>
</div>
</body>
You're aligning the text elements like this:
margin-left: 100%;
margin-right: 100%;
This positions each element – from the starting point of the box – to the left and right edges.
Hence, the left edge of the left-moving box will align with the left edge of the container.
And the left edge of the right-moving box will align with the right edge of the container. This causes the rest of this box to overflow.
Try this instead:
margin-right: 90%; /* adjust as needed */
Edit based on revised question
Here is an alternative solution that works regardless of content width.
.header {
position: fixed;
width: 70%;
background-color: springgreen;
}
.title, .menu {
text-align: center;
position: relative;
width: 100%;
height: 50px;
}
.trans-left {
position: absolute;
left: 50%;
transform: translateX(-50%);
transition: 1s;
}
.trans-right {
position: absolute;
right: 50%;
transform: translateX(50%);
transition: 1s;
}
.header:hover .trans-left {
left: 0;
transform: translateX(0);
transition: 1s;
}
.header:hover .trans-right {
right: 0;
transform: translateX(0);
transition: 1s;
}
<div class="header">
<div class="title">
<span class="trans-left">This one goes left</span>
</div>
<div class="menu">
<span class="trans-right">This one goes right</span>
</div>
</div>
More details: Element will not stay centered, especially when re-sizing screen

Firefox not displaying header correctly

I have a question regarding my previous post:
Animation stop with css3
The slider works perfect in Chrome. In firefox however it is not working properly. Does anyone here have an idea?
Slider can be found here http://jimmytenbrink.nl/slider/
It looks like there is a problem in firefox with positioning absolute + display: table-cell.
My code is as follows:
<header>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div >
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
<div>
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
</header>
And the css;
header {
margin-top: 10px;
width: 1185px;
display: table;
overflow: hidden;
background-color: #000;
height: 500px;
}
header > div {
background: url('./images/iron_man_bg.jpg');
width: 123.8px;
height: 500px;
position: relative;
-webkit-transition: width .3s;
transition: width .3s;
display: table-cell;
border: 2px solid #fff;
overflow: hidden;
}
header div:first-child {
margin-left: 0px;
}
header div:last-child{
margin-right: 0px;
}
header div:hover span {
left: 50px;
opacity: 1;
}
header > div img {
position: absolute;
left: -240px;
-webkit-transition: all .3s;
transition: all .3s;
-webkit-filter: grayscale(1);
overflow:hidden;
}
header > div span {
-webkit-transition: left .3s;
transition: left .3s;
position: absolute;
bottom: 30px;
color: white;
left: -70px;
opacity: 0;
width: 151px;
font-family: 'Fugaz One', cursive;
text-transform: uppercase;
color: #fff;
font-size: 24px;
text-shadow: 0px 0px 10px #f1f1f1;
filter: dropshadow(color=#f1f1f1, offx=0, offy=0);
}
header > div:hover {
width: 920px;
}
header div:hover img {
left: 0px;
-webkit-filter: grayscale(0);
}
Here is what works:
http://codepen.io/jeremyzahner/full/cAEbv
Basically, i added a new container inside the "div" with class .inside. On that i do width:100%; height:100; position:relative; overflow:hidden;. Plus, i did remove the fixed height on the outer divs, since the header already holds that fixed height, it is not necessary to set it again.
It is a knonw "bug" of firefox that it treats display:table-cell; divs like that. I don't think they will fix it soon. So the best workaround (at least in my experience) is another inner wrapper like here.
CSS Modification:
header > div .inside {
position:relative;
width:100%;
height:100%;
overflow:hidden;
}
header > div {
background: url('./images/iron_man_bg.jpg');
width: 123.8px;
position: relative;
-webkit-transition: width .3s;
transition: width .3s;
display: table-cell;
border: 2px solid #fff;
overflow: hidden;
}
HTML Modification:
<div>
<div class="inside">
<img src="./images/ironman.png">
<span>Ironman</span>
</div>
</div>
This was tested in actual version of Chrome and Firefox (on Ubuntu).
Hope this helps