would you know why my red div (.block) is placed above the blue wrapper and not within? Also would expect the text to be within the red DIV as well. Thanks http://jsfiddle.net/B3CL6/
HTML:
<div class="wrapper blue-background ">
<div class="block width100">
<div class="block-left">
<h3>Block left </h3>
</div>
<!-- End DIV block-left -->
<div class="block-right">
<h1>block right</h1>
</div>
<!-- End DIV block-right -->
</div>
<!-- End DIV block width100 -->
</div>
<!-- End wrapper -->
CSS:
.wrapper {
position: relative;
display: block;
margin-right: auto;
margin-left: auto;
width: 980px;
overflow: hidden;
}
.block {
padding: 20px;
text-align: justify;
background-clip: border-box;
box-sizing: border-box;
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
background: red;
}
.width100 {
width: 100%;
}
.top {
margin-top: 30px;
}
.blue-background {
background: #124191;
}
.block-left {
float: left;
box-sizing: border-box;
width: 50%;
}
.block-right {
float: right;
overflow: hidden;
box-sizing: border-box;
width: 50%;
}
As far as i understand is you want the Red Block inside the Blue Block. if so
try this. set the padding-top:10px to Padding:10px
.wrapper {
position: relative;
display: block;
margin-right: auto;
margin-left: auto;
width: 980px;
overflow: hidden;
padding: 10px;
}
and if you want the text inside that do something like this or add another style for the "Block Right" text
H1{
display: inline;
}
Red div(.block) is actually present inside Blue div(.wrapper). As suggested by JoshC you can check it by making your red background as semi-transparent.
To get the text to be within the red DIV,
Remove overflow: hidden; property from .wrapper class and add it to .block class.
That should solve your problem.
Related
I have a scrollable list of divs that each have a border-radius and box-shadow. To allow an element below the list to remain visible, the list is cut off using clip-shape. I would like to keep both the shadow and border radius of the clipped rectangles. I have found several working examples for either the shadow or the radius, but I can't find anything that can do both at the same time.
#main {
background-color: lightblue;
position: relative;
height: 100vh;
width: 100vw;
overflow-y: hidden;
}
body {
margin: 0;
}
#overlay {
width: 100vw;
height: 95vh;
overflow-y: scroll;
position: absolute;
clip-path: inset(5vh 0px 0px);
padding-top: 5vh;
}
#overlay::-webkit-scrollbar {
display: none;
}
.overlay-card {
margin: 10px 10px 30px;
background-color: white;
border-radius: 10px;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
height: 500px;
padding: 30px;
}
<div id="main">
<center>root/header</center>
<div id="overlay">
<div class="overlay-card">overlay content</div>
<div class="overlay-card">overlay content</div>
</div>
</div>
Is the effect above possible? Am I approaching this problem correctly?
I have a div like this:
Now I need to remove a part of the circle from this shape which is shown as below:
Therefore the final shape would be looked like this:
So I decided to put the image as the background of my div.
<div class="col-4 customBack">
<div class="mainInfo">
<div class="circle2">
<img src="https://sitename.com/images/image.png">
</div>
<div class="paraDivRight2">
<h6 style="margin-top:5px;"><strong>Lorem Ipsum Dolor Simit</strong></h6>
<hr style="margin-top:-5px;">
<p style="margin-top:-10px;">012-3456789</p>
<p style="padding-top:5px;">ifno#sitename.com</p>
</div>
</div>
</div>
And here are the styles:
.mainInfo{
background-color: #fff;
border: .01rem round #e0e1ed;
border-radius: 20px;
color: #585CA1;
width:100%;
height:5em;
box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.75);
margin-top: 3em;
display: flex;
align-items: center;
justify-content: center;
}
.customBack{
background-image: url("/img/shadow3.png") !important;
}
.circle2 {
position: relative;
left:-60%;
width: 9em;
height: 9em;
background: #fff;
border-radius: 50%;
box-shadow: 0px 0px 17px -5px rgba(0,0,0,0.65);
}
.circle2 img {
position: absolute;
max-width: 85%;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 100;
}
.paraDivRight2 {
position: absolute;
display: inline-block;
padding: 10px;
color:black;
top:0px !important;
padding-top:50px !important;
right: 20px;
text-align: right;
padding-right:50px !important;
}
.paraDivRight2 p {
line-height: 1em;
font-size: 10pt;
margin: 0;
letter-spacing: 1px;
}
As you can see I have put the background in .customBack class But the result is now looks like this:
So the question is, how can I properly place this background image which is (shadow3.png) as background image of this mainInfo div so the side of circle shape that needs to be removed, does not appear...
I'm really stuck with this, so please help me out...
Use CSS filter: drop-shadow() MDN Docs on a wrapper element.
Fix your class naming to use a friendlier convention
Use CSS flex for a simpler alignment of your elements
Stop using inline HTML style attributes
/* Quick Reset */
* {
margin: 0;
box-sizing: border-box;
}
.custom {
filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.4));
display: flex;
flex-wrap: nowrap;
align-items: center;
}
.custom-image {
width: 9em;
height: 9em;
background: #fff;
border-radius: 50%;
padding: 1em;
}
.custom-image img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 50%;
}
.custom-content {
position: relative;
background: #fff;
padding: 1em;
text-align: right;
border-radius: 0 1em 1em 0;
padding-left: 2em;
left: -1em;
}
.custom-content h4 {
border-bottom: 1px solid #ddd;
}
<div class="custom">
<div class="custom-image">
<img src="https://i.stack.imgur.com/qCWYU.jpg?s=256&g=1">
</div>
<div class="custom-content">
<h4>Lorem Ipsum Dolor Simit</h4>
<p>012-3456789</p>
<p>ifno#sitename.com</p>
</div>
</div>
I'm not 100% sure about this but it has worked for me in the past,try making the position attribute of the div relative and make it absolute for the image,then size it properly.
I created a div with a border-radius 4% and wanted to add a div inside it. But now the border-radius is getting affected. How can I add the new div without affecting the previous border-radius.
If I add same border radius for the inner div
Without any border-radius
body {
background: #4FA2AD;
}
.upper {
background-color: #035961;
height: 30%;
}
.main {
background-color: antiquewhite;
height: 50vh;
width: 25%;
margin: 25vh auto;
border-radius: 4%;
box-shadow: 2px 2px 2px 2px rgba(0,0,0,0.2);
}
<body>
<div class="main">
<div class="upper">
</div>
</div>
</body>
Overflow hidden will cut off any content that goes outside of the parents border, including any overlap at the corners.
overflow: hidden;
This is sometimes not a viable solution (Where you require content to overflow or extend the container) however since you have a fixed size, it is valid in this case.
body {
background: #4FA2AD;
}
.upper {
background-color: #035961;
height: 30%;
}
.main {
background-color: antiquewhite;
height: 50vh;
width: 25%;
margin: 25vh auto;
border-radius: 4%;
box-shadow: 2px 2px 2px 2px rgba(0,0,0,0.2);
overflow: hidden;
}
<body>
<div class="main">
<div class="upper">
</div>
</div>
</body>
I'm trying to create a div that stays under the bottom of the page and is invisible there. I mean, you can't scroll to it. I tried to google it, but I just can't make it, neither negative bottom-margin, nor negative bottom, nor relative/absolute positioning couldn't make it...
Could anyone of you help me, please?
Here's a snippet of my site - I wanna "Menu" image to be invisible on the bottom (outside the display area), so it can then slide up when needed.
body {
overflow-x: hidden;
margin: 0;
padding: 0;
}
.main-container {
width: 100vw;
height: 100vh;
background-color: #780d0d;
position: absolute;
}
.mainmenu {
width: 70vw;
height: 82vh;
position: relative;
top: 8vh;
left: 15vw;
-webkit-box-shadow: 0px 0px 66px 10px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 66px 10px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 66px 10px rgba(0, 0, 0, 0.75);
}
.menu-bottom {
height: 20%;
width: 33.2%;
background-color: red;
border: 1px solid;
display: inline-block;
margin: 0 -5px 0 0;
}
.menu-side-holder {
height: 80%;
width: 30%;
display: inline-block;
}
.menu-side {
height: 50%;
background-color: red;
border: 1px solid;
display: block;
margin: 0;
vertical-align: top;
}
#menu-img {
height: 80%;
width: 40%;
display: inline-block;
margin: 0 -4px;
vertical-align: top;
clear: none;
}
.menu-bottom-slider {
display: inline-block;
width: 100%;
background-color: green;
}
#slider {
position: absolute;
padding-left: 43.5%;
bottom: 0;
margin-bottom: -30vh;
}
<div class="main-container">
<div class="mainmenu">
<div class="menu-side-holder">
<div class="menu-side" id="ogloszenia">
1
</div>
<div class="menu-side">
3
</div>
</div>
<img id="menu-img" src="img/main4.jpg">
<div class="menu-side-holder">
<div class="menu-side">
3
</div>
<div class="menu-side">
4
</div>
</div>
<div class="menu-bottom">
5
</div>
<div class="menu-bottom">
6
</div>
<div class="menu-bottom">
7
</div>
<div class="menu-bottom-slider">
<img id="slider" src="http://s32.postimg.org/xrrmzmohx/slider.png">
</div>
</div>
</div>
place your target div as direct child of body (not nested inside other divs) and use this style:
position:absolute;
bottom:-100% // or fixed size if height is known
One way you might be able to do this is by making it absolute and give it a negative bottom equal to the height of the element like so
.menu-bottom-slider{
position: absolute;
bottom: -(height of element goes here)px
}
Why don't you put
opacity: 0
on the element and position it where you need it ON the page. Then when you want to use it, use jQuery to change the opacity and animate it.
This would be the css of your div section.
#divname {
position:fixed;
height:50px;
background-color:red;
bottom:0px;
left:0px;
right:0px;
margin-bottom:0px;
}
Your body would look like this.
**body{
margin-bottom:50px;
}**
Your code is nearly working, but you are using overflow-x, and you need overflow-y.
EDIT:
Another way is to set the position of the slider to fixed. This means that the position does not depend on the scroll position, so you can't scroll to it:
body {
overflow-x: hidden; /* you could also change this to overflow-y */
margin: 0;
padding: 0;
}
.main-container {
width: 100vw;
height: 100vh;
background-color: #780d0d;
position: absolute;
}
.mainmenu {
width: 70vw;
height: 82vh;
position: relative;
top: 8vh;
left: 15vw;
-webkit-box-shadow: 0px 0px 66px 10px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 66px 10px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 66px 10px rgba(0, 0, 0, 0.75);
}
.menu-bottom {
height: 20%;
width: 33.2%;
background-color: red;
border: 1px solid;
display: inline-block;
margin: 0 -5px 0 0;
}
.menu-side-holder {
height: 80%;
width: 30%;
display: inline-block;
}
.menu-side {
height: 50%;
background-color: red;
border: 1px solid;
display: block;
margin: 0;
vertical-align: top;
}
#menu-img {
height: 80%;
width: 40%;
display: inline-block;
margin: 0 -4px;
vertical-align: top;
clear: none;
}
.menu-bottom-slider {
display: inline-block;
width: 100%;
background-color: green;
}
#slider {
position: fixed; /* This fixes the slider, you can't scroll to it! */
padding-left: 43.5%;
bottom: 0;
margin-bottom: -30vh;
}
<div class="main-container">
<div class="mainmenu">
<div class="menu-side-holder">
<div class="menu-side" id="ogloszenia">
1
</div>
<div class="menu-side">
3
</div>
</div>
<img id="menu-img" src="img/main4.jpg">
<div class="menu-side-holder">
<div class="menu-side">
3
</div>
<div class="menu-side">
4
</div>
</div>
<div class="menu-bottom">
5
</div>
<div class="menu-bottom">
6
</div>
<div class="menu-bottom">
7
</div>
<div class="menu-bottom-slider">
<img id="slider" src="http://s32.postimg.org/xrrmzmohx/slider.png">
</div>
</div>
</div>
I created a container. Plain text in the container displays inside the container, however, formatted text displays outside of the container. Please give suggestions. My html and css are posted below.
This is my html:
.left-column {
text-align: left;
float: left;
width: 40%;
padding-left: 5px;
}
.right-column {
text-align: left;
float: left;
width: 50%;
padding-left: 200px;
}
#container {
width: 900px;
background-color: #ffffff;
border: 1.5px solid #FFCC99;
margin: 0;
padding: 10px;
}
.border1 {
width: 910px;
border: 3px solid #376092;
margin: 1px;
padding: 2px;
}
border2 {
width: 915px;
border: 2px solid #FFCC99;
margin: 12px auto 12px auto;
}
<main id="gap">
<div class="border2">
<div class="border1">
<div id="container">
<div class="left-column">
</div>
<div class="right-column">
</div>
</div>
<!-- End Container -->
</div>
<!-- End Border1 -->
</div>
<!-- End Border2 -->
</main>
because you are floating the .left-column and .right-column, you should use a clearfix
Also I would advise you to use box-sizing:border-box, see more about border box model
Here is a snippet:
.cf:before,
.cf:after {
content: " ";
display: table;
}
.cf:after {
clear: both;
}
*, *:before, *:after {
box-sizing: border-box;
}
.left-column {
text-align: left;
float: left;
width: 40%;
padding-left: 5px;
}
.right-column {
text-align: left;
float: left;
width: 50%;
/*padding-left: 200px; - this can be removed */
}
#container {
width: 900px;
background-color: #ffffff;
border: 1.5px solid #FFCC99;
margin: 0;
padding: 10px;
}
.border1 {
width: 910px;
border: 3px solid #376092;
margin: 1px;
padding: 2px;
}
.border2 {
width: 915px;
border: 2px solid #FFCC99;
margin: 12px auto 12px auto;
}
<main id="gap">
<div class="border2">
<div class="border1">
<div id="container" class="cf">
<div class="left-column">text left</div>
<div class="right-column">text right</div>
</div>
<!-- End Container -->
</div>
<!-- End Border1 -->
</div>
<!-- End Border2 -->
</main>
Set overflow:hidden in #container. This will force the container to respect the height of all elements within it, regardless of floating elements.
CSS
#container {
width:900px;
background-color: #ffffff;
border:1.5px solid #FFCC99;
margin: 0;
padding:10px;
overflow: hidden; /* Set this rule */
}
DEMO HERE
The problem is your padding on your #container.
Your css is :
padding: 10px and width: 910px
So, your padding add 20px (10px right, 10px left).
In the end, your #containter width is 920px and your parent div is 910px.
To fix your problem, you need to set the width of your parent to 920 or change the padding to : padding:5px;