I have an element with a slanted bottom-right corner, over which I have to lay a box-shadow. Sometimes the slanted corner is covered up by a badge - my problem does not apply, if that is the case:
This is the (s)css part for the infobox and its corners (there are some more styles, but they're just text modifiers... The whole thing is on codepen: https://codepen.io/kerowan/pen/bqMOeB
.product-info-wrapper {
position: absolute;
top: 150px;
max-width: 100%;
padding-bottom: 10px;
width: 100%;
.product-info {
position: relative;
padding: 1rem * .5;
padding-right: 1rem * 2;
overflow: hidden;
box-shadow: 0 0 5px;
&:before,
&:after {
position: absolute;
content: "";
left: 0;
z-index: -1;
background-color: lighten(#000, 93.5%);
border-color: lighten(#000, 93.5%);
}
&:before {
top: 0;
right: 0;
bottom: 35px;
}
&:after {
top: auto;
right: -5px;
bottom: 0;
border-style: solid;
border-width: 35px 35px 0 0;
background-color: transparent;
border-right-color: transparent;
}
}
}
How can this be done (moving the shadow along the slanted corner)? Can it be done, if the slanted corners are generated the way I do it? I'm kind of dependant on those classes (I think at least) because of all the relative and absolute positioning, which I needed to place the corner badge.
EDIT: some HTML, if you need it:
<div class="swiper-slide">
<div class="product-info-wrapper">
<div class="product-info">
<div class="row no-gutters">
<div class="col-8">
<strong class="text-uppercase">Amino Force</strong>
<span class="product-info-link">Kurzinfo</span>
</div>
<div class="col-4 text-right">
<span class="product-info-price">CHF 34.00</span>
</div>
</div>
</div>
</div>
</div>
<div class="swiper-slide">
<div class="product-info-wrapper">
<div class="product-info">
<div class="row no-gutters">
<div class="col-8">
<strong class="text-uppercase">Amino Force</strong>
<span class="product-info-link">Kurzinfo</span>
</div>
<div class="col-4 text-right">
<span class="product-info-price">CHF 34.00</span>
</div>
</div>
</div>
<div class="product-badge-wrapper">
<div class="product-badge red">
<div class="product-badge-content">
new
</div>
</div>
</div>
</div>
</div>
This is just part of the whole HTML code which can be found on the codepen thingy. But I guessed, that this would be the only relevant part. If you need more, please tell me!
EDIT2
The contents of this infobox can be expanded. If I click on "Kurzinfo", it expands and shows more info. That's not on the codepen version, as I created it way before I added the expansion functionality.
It is normally impossible, because the slanted corner is a part of border of element that is not visible.
In image if the blue area changes to white you have a slanted corner black area, that is a part of border and in css we can not any think to change this.(change as you want).
You can cover the shadows by adding two little divs to the product div:
<div class="product-info-wrapper">
<div class="coverShadow c1"></div>
<div class="coverShadow c2"></div>
....
And CSS:
.coverShadow {
position: absolute;
z-index: 999;
background-color: white;
box-shadow: 0 0 14px white;
}
.coverShadow.c1 {
width: 10px;
height: 35px;
background-color: white;
bottom: 8px;
right: -10px;
}
.coverShadow.c2 {
width: 35px;
height: 10px;
bottom: 0px;
right: 0;
}
By changing the box shadow and width/height and right/bottom of covering divs it could be more smooth.
And thanks for the good idea for creating slanted corners.
As of 2022 you could get rid of the elements and styles .coverShadow, .coverShadow.c1 and coverShadow.c2 suggested by #Farzin's answer. Instead, for the .product-info element replace
box-shadow: 0 5px 5px
with
filter:drop-shadow(0 0 5px #333)
(blur amount and color might need to be adjusted).
The drop-shadow() will adapt to any shape, not just rectangles. It will also work in most modern browsers.
Related
I'm trying to get a response line next to a heading
Picture above is from a pdf not the site
I tried using a Div with a border bottom but its out of place because its a border it sits lower, I then tried using a <hr And The same thing it doesnt align properly There are one's at the bottom center ect.
How do I achieve something of the sorts without having to set responsive stylings every few pixel's.
<div class="container">
<div class="we-are">
<div class="row">
<div class="col-md-4">
<h2>We are.</h2>
</div>
<div class="col-md-8 line-right">
<hr>
</div>
</div>
</div>
</div>
.line-right hr{
position: absolute;
bottom: 0;
width: 100%;
border: 0;
border-bottom: 5px #BFE2CA solid;
}
My result:
I do realize I can ofcourse do something like
marign-top:50px
But it wont be very responsive
I would suggest a different approach using pseudo-elements
Here your HTML code:
<div class="container">
<div class="we-are">
<div class="row">
<div class="parent">
<h2>We are.</h2>
</div>
</div>
</div>
</div>
And here your CSS, where the line is made by the _pseudo-element after:
h2 {
margin: 0;
}
.parent {
position: relative;
width: auto;
display: inline-block;
}
.parent:after{
display: block;
content: "";
position: absolute;
bottom: 4px;
left: calc(100% + 20px);
width: 500px; /* Or whatever you need, e.g. width: calc(100vw - 200px); */
height: 5px;
background: #BFE2CA;
}
If you want to have the line vertically aligned just change your CSS accordingly (remove bottom and add top):
top: 50%;
transform: translateY(-50%);
Here's a working live Codepen: https://codepen.io/alezuc/pen/dyYGxYY
Yous should use something like dynamic when the font or the screen varies, you have to set the line to the period symbol first and then even if you increase/decrease the font that shouldn't change the line.
you can try something like this. you can try to change the font and you see the line sticks to the same position and you just have to increase the height of the line based on font.
Snippet
* {
padding: 0;
margin: 0;
border: 0;
}
.container {
margin: 5px;
border: 1px solid red;
}
.parent {
position: relative;
width: auto;
display: inline-block;
font-size:3em; /* change the size and see the difference */
}
.parent:after {
content: "";
position: absolute;
bottom: 20%;
left: calc(100% + 20px);
width: 500px;
/* height is the only thing you have to change irrespective of the font. */
height: 5px;
background: #BFE2CA;
}
<div class="container">
<div class="we-are">
<div class="row">
<div class="parent">
<h2>We are.</h2>
</div>
</div>
</div>
</div>
I am trying to assign the button : called 'go to form' right at the bottom of the grid i have done in CSS.
I have messed around with the relative position but this seems not to want to work. Any ideas guys ?
.item {
border: 1px rgb(160,160,255) solid;
}
img {
border-radius: 2px;
border: 1px solid #ddd;
height : 100px;
width : 80%;
}
p {
font-size: 18px;
}
h1 {
font-size: 14px;
}
</style>
<div class="grid-container">
<div class="item">
<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>
<p> Sheep Dipper </p>
</div>
<div class="item"><img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>
<p> Laptop Request </p>
<h4> Use this form to request a new laptop</h4>
<button>Go to Form</button> </div>
<div class="item">
<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>
<p> New User Request </p>
</div>
<div class="item">
<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/>
<p> Permissions Management </p>
</div>
<div class="item">
<img src="/sites/TeamSite/SiteAssets/placeholder.jpg" alt="Paris"/> <br/><br/><br/><br/><br/></div>
</div>
try this one :
.grid-container{
position: relative;
}
.youBtnClass {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
Try this. Position absolute will place the button with respect to its immediate parent, and bottom attribute makes sure it starts at the very bottom of the parent.
You may add top margin in case your button lacks a gap on top of it.
.grid-container{
position: relative;
}
.youBtnClass {
position: absolute;
bottom: 0;
margin: 0 auto;
}
I have an overlay over a clip thumbnail, and a click event to open the iFrame. The overlay will contain the JSON response data about the clip, however, I'm having trouble styling the overlay to not include the margins in the overlay's total size. This, for obvious reasons, makes aligning text very problematic.
So how would I make it so the overlay takes that same margin, without adding the margin to the overlay effectively doubling the margin entirely?
#clips {
overflow-x: scroll;
overflow-y: hidden;
display: flex;
}
.clipImg {
flex: 1;
margin-bottom: 1em;
padding-right: 1em;
}
.clipImg-overlay {
position: absolute;
display: block;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 496;
height: 272;
opacity: 0;
transition: .5s ease;
background-color: rgba(0, 0, 0, .7);
font-family: sans-serif;
}
.clipImg-container:hover .clipImg-overlay {
opacity: 1;
}
<div class="clipImg-container" data-slug="ManlyEnjoyableSowKappaPride"><img src="https://clips-media-assets2.twitch.tv/28966899744-offset-8838-preview-480x272.jpg" class="clipImg">
<div class="clipImg-overlay"><img id="channel-logo" src="https://static-cdn.jtvnw.net/jtv_user_pictures/d7747302-0948-478a-9017-976d285a2678-profile_image-150x150.png">
<div id="info-container">
<h1 id="clip-name">CODE BLUE CODE BLUE | Tip for free !loots</h1>
<p id="clip-context">CodeSpent is playing PLAYERUNKNOWN'S BATTLEGROUNDS</p>
<p id="clip-views">4 views</p>
<p id="clip-curation">Clipped by sudocodesh</p>
</div>
</div>
</div>
The .clipImg-overlay is relative to the .clipImg-container, that expands with the .clipImg margin.
To resolve this you could try to use the margin in the .clipImg-container or make a div that surrounds .clipImg-overlay and .clipImg and have the margin that is actually in .clipImg.
<style>
.clipImg {
flex: 1;
}
.clipImg-container {
margin-bottom: 1em;
padding-right: 1em;
}
</style>
<div class="clipImg-container" data-slug="ManlyEnjoyableSowKappaPride">
<img src="https://clips-media-assets2.twitch.tv/28966899744-offset-8838-preview-480x272.jpg" class="clipImg">
<div class="clipImg-overlay">
<img id="channel-logo" src="https://static-cdn.jtvnw.net/jtv_user_pictures/d7747302-0948-478a-9017-976d285a2678-profile_image-150x150.png">
<div id="info-container">
<h1 id="clip-name">CODE BLUE CODE BLUE | Tip for free !loots</h1>
<p id="clip-context">CodeSpent is playing PLAYERUNKNOWN'S BATTLEGROUNDS</p>
<p id="clip-views">4 views</p>
<p id="clip-curation">Clipped by sudocodesh</p>
</div>
</div>
</div>
or
<style>
.overlay-container {
position: relative;
margin-bottom: 1em;
padding-right: 1em;
}
</style>
<div class="clipImg-container" data-slug="ManlyEnjoyableSowKappaPride">
<div class="overlay-container">
<img src="https://clips-media-assets2.twitch.tv/28966899744-offset-8838-preview-480x272.jpg" class="clipImg">
<div class="clipImg-overlay">
<img id="channel-logo" src="https://static-cdn.jtvnw.net/jtv_user_pictures/d7747302-0948-478a-9017-976d285a2678-profile_image-150x150.png">
<div id="info-container">
<h1 id="clip-name">CODE BLUE CODE BLUE | Tip for free !loots</h1>
<p id="clip-context">CodeSpent is playing PLAYERUNKNOWN'S BATTLEGROUNDS</p>
<p id="clip-views">4 views</p>
<p id="clip-curation">Clipped by sudocodesh</p>
</div>
</div>
</div>
</div>
The text inside of my progress bars are getting cut off on the top. I'd like to move the text to the middle of the progress bar.
How can I do so?
I've tried position: relative; and top: 40px but that is causing issues for me when I dynamically change the number (with JS). Oddly, the number is getting cut off on the top even when it appears in the middle of the progress bar. Even more odd is that is only happening in Chrome (FF and IE work fine).
Notice in this image, only the bottom changed, but the top part didn't:
So, I included a live example WITHOUT the relative positioning, I'm thinking that that is the reason things are wacky. Can you guys figure out how to just move the text down to the middle without relative positioning? Or just figure out how to prevent the number from getting cut off with the relative positioning?
Also, I don't want absolute positioning either because the number needs to remain in the middle of each individual progress bar.
LIVE EXAMPLE: http://jsfiddle.net/SeTXK/1/
HTML:
<div class="row">
<div class="col-md-12">
<div class="content">
<h2>Summary</h2>
<div class="progress text-center">
<div class="progress-bar progress-bar-success" role="progressbar">
<span id="output-expenses">$0.00</span>
</div>
<div class="progress-bar progress-bar-warning" role="progressbar">
<span>$0.00</span>
</div>
<div class="progress-bar progress-bar-danger" role="progressbar">
<span>$0.00</span>
</div>
<div class="progress-bar progress-bar-income" role="progressbar">
<span id="output-income"></span>
</div>
</div>
</div>
</div>
</div>
CSS:
.progress {
height: 100px;
margin-bottom: 0;
border-radius: 10px;
/*background-color: #c4ffc4;*/
}
.progress span {
/*position: relative;
top: 40px;*/
color: #292929;
font-weight: bold;
font-size: 4em;
font-family: 'Cinzel', serif;
text-align: center;
vertical-align: middle;
width: 100%;
}
.progress-bar-success {
width: 30%;
}
.progress-bar-warning {
width: 20%;
}
.progress-bar-danger {
width: 20%;
}
.progress-bar-income {
background-color: #f5f5f5;
-webkit-box-shadow: inset 0 5px 8px rgba(0,0,0,0.1);
box-shadow: inset 0 5px 8px rgba(0,0,0,0.1);
width: 30%;
}
If you add padding-top:75px; display:inline-block; to the .progress span rule, it will achieve the desired effect.
jsFiddle
I've searched the many similar questions like this, but none of the solutions are working. It should also be noted that I am using twitter bootstrap. I want a bunch of divs to span the entire length of the parent div at the bottom of it. I have tried putting them inside a div that text-align:center and then using float-left inside the gridPics class, and using display: inline-block, text-align :left and nothing seems to do it. The two in the example below are in the exact same spot, and I want them side by side. Here is what I have:
HTML:
<div class="row-fluid">
<div class="span8 offset2 articleContent">
<!-- These are the divs to span across, when it works there would be more than two -->
<div class="gridPics"></div>
<div class="gridPics"></div>
<!-- They will also go over this image -->
<img id="sidePic" src="img/about/aboutHeader_Mid1.png" alt="about">
</div>
<div class="span2"></div>
</div>
CSS:
.gridPics{
position: absolute;
z-index: 1;
width: 10%;
height: 20%;
background: #0000b3;
bottom: 0;
float: left;
}
.articleContent{
position: relative;
box-shadow: 0 0 5px 5px #888;
}
#sidePic{
position: relative;
z-index: -1;
}
Here is where I am doing this, the blue divs would be pics (akin to thumbnails) that can be clicked. I want them to go all the way across:
/ScreenShot2013-01-09at85450PM_zps550e8e4a.png[/IMG]
Here's a fiddle:
http://jsfiddle.net/pureux/Er9eG/
You need a container for your gridPics and have it be absolute positioned (instead of the gridPics) at the bottom. Then float the gridPics inside of the container.
.picContainer {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
min-height: 50px;
}
.gridPics {
width: 50px;
height: 50px;
float: left;
display: block;
margin-right: 4px;
margin-top: 4px;
}
Is this what you're trying to do:DEMO
HTML
<div class="row-fluid">
<div class="span8 offset2 articleContent">
<div class="gridPics"></div>
<div class="gridPics"></div>
<div class="clear"></div>
<img id="sidePic" src="img/about/aboutHeader_Mid1.png" alt="about">
</div>
<div class="span2"></div>
</div>
CSS
.gridPics{
width: 10%;
height: 20px;
background: #0000b3;
float: left;
border:solid #FFF 1px;
}
.articleContent{
box-shadow: 0 0 5px 5px #888;
}
#sidePic{
z-index: -1;
}