In the left part of the following picture you can see an object which has been positioned on the right edge of the container. Part of the object is cut off according to the overflow property and can be displayed by scrolling horizontally to the right.
In the right part of the picture you can see the object after scrolling to the right. The shadow on the right edge of the object is cut off. When scrolling, only the extent (width) of the object without the shadow was taken into account.
Setting a margin or padding value for the object did not change the behavior. Experiments with the css property scrolling-margin or scrolling-padding have also failed.
The behavior was tested under Chrome (79.0.3945.88), Opera and Edge in the latest versions under Mac OS.
I don't want to create another container around the object to create a space. Is there any other way to avoid cutting off the shadow?
The relevant CSS for the container:
margin: 4px;
box-sizing: border-box;
overflow: auto;
The relevant CSS for the object:
background: lightgreen;
background-clip: padding-box;
box-sizing: border-box;
border-width: 1px;
border-style: solid;
border-color: darkslategray;
border-radius: 50%;
box-shadow: 2px 2px 4px gray;
position: absolute;
How about this. Put something in the ::after of the divs and position that slightly to the right.
It sounds like a bit of a kludge, but of all the things I tried, this is the only trick I could get to work.
/* Change line 34 to see the beauty of flex-design ;-) */
body {
width: 100vw;
height: 100vh;
margin: 0;
background-color: white;
overflow: hidden;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: flex-start;
align-content: stretch;
align-items: stretch;
}
nav {
box-sizing: border-box;
background-color: yellow;
opacity: 0.9;
display: flex;
align-items: center;
user-select: none;
flex: 0 0 35px;
padding: 5px;
border-bottom: 4px solid #ddd;
}
main {
box-sizing: border-box;
flex: 1 1 auto;
align-self: stretch;
display: flex;
flex-direction: row; /* row, row-reverse, column, column-reverse */
flex-wrap: nowrap;
justify-content: flex-start;
align-content: stretch;
align-items: stretch;
}
article {
--raster: 25px;
--raster-color: #ddd;
margin: 4px;
box-sizing: border-box;
overflow: scroll;
background-attachment: local;
background-image: linear-gradient(var(--raster-color) 1px, transparent 1px), linear-gradient(90deg, var(--raster-color) 1px, transparent 1px), linear-gradient(var(--raster-color) 0.5px, transparent 0.5px), linear-gradient(90deg, var(--raster-color) 0.5px, transparent 0.5px);
background-size: var(--raster) var(--raster), var(--raster) var(--raster), 5px 5px, 5px 5px;
flex: 3 1 75%;
align-self: auto;
position: relative;
}
section {
box-sizing: border-box;
background-color: #ddd;
flex: 0 0 4px;
cursor: col-resize;
}
aside {
box-sizing: border-box;
background-color: lightgray;
overflow: scroll;
flex: 1 1 calc(25% + 10px); /* resizing */
align-self: auto;
margin: 4px;
padding: 5px;
}
article div {
position: absolute;
border: 1px solid black;
border-radius: 50%;
box-shadow: 4px 4px 8px gray;
width: 100px;
height: 100px;
background-color: lightgreen;
color: white;
}
/* Trick goes here */
article div::after {
position: absolute; bottom:-8px; right: -8px;
display: inline; content: '\00A0';
}
article div:nth-child(1) {
left: 500px;
top: 50px;
}
article div:nth-child(2) {
left: 350px;
top: 10px;
}
article div:nth-child(3) {
left: 175px;
top: 125px;
}
<nav>
navigation bar
</nav>
<main>
<article>
<div>
first
</div>
<div>
second
</div>
<div>
third
</div>
</article>
<section></section>
<aside>
input area
</aside>
</main>
Related
My submit button moves when I resize the page. This behavior is bad (obviously). What is the correct way to make it so that my button is left aligned to my textarea?
#chatboxTranscript {
width: 31.25em;
/* padding: 0em; */
background-color: #36393f;
color: #fff;
display: flex;
border: 0.125em solid #000;
/* Increase border width */
border-radius: 0.3125em 0.3125em 0 0;
/* Round the border */
box-sizing: border-box;
margin: 0 auto;
height: 12.5em;
/* Maintain the height */
}
#chatboxInput {
top: -0.125em;
height: 3.35em;
left: -2.2em;
width: 37.3em;
/* Keep the width the same */
background-color: #36393f;
/* Keep the color the same */
border: 0.15em solid #000;
border-radius: 0 0 0.3125em 0.3125em;
/* Round the border */
padding-bottom: 1.5em;
box-sizing: border-box;
margin: 0 auto;
display: flex;
/* border-top: none; */
position: relative;
}
.input-group {
display: flex;
justify-content: space-between;
}
button[type="submit"] {
position: relative;
display: inline-block;
width: 4em;
top: -0.1em;
height: 3em;
margin: 0 -2em;
border: 0.125em solid #000;
background-color: #36393f;
border-radius: 0.3125em;
}
<div id="chatbox" class="chatbox" data-role="chatbox">
<div id="chatboxTranscript" class="chatbox-transcript"></div>
<div class="input-group">
<!-- <form action="#" onsubmit="handleChatboxFormSubmit(event);"> -->
<textarea type="text" name="chatboxInput" id="chatboxInput" /> </textarea>
<button type="submit">Submit</button>
<!-- </form> -->
</div>
</div>
I tried multiple ways of fixing using absolute positioning (still same behavior), display (did nothing), margin (moves my textarea to the left) and asking chatgpt (output nonsensical CSS that didn't work).
Is this what you're trying to achieve?
I've removed all position layout styles since they don't help much in your particular layout.
The main issue was the .input-group since it didn't have a width and you're using flex for the layout. The content would take the entire width from its parent (#chatbox) therefore the button went to the right-hand side of the screen.
To fix this, I simply added a width for the .input-group as well as a margin of auto so it now aligns nicely with #chatboxTranscript div.
#chatboxTranscript {
width: 31.25em;
background-color: #36393f;
color: #fff;
display: flex;
border: 0.125em solid #000; /* Increase border width */
border-radius: 0.3125em 0.3125em 0 0; /* Round the border */
box-sizing: border-box;
margin: 0 auto;
height: 12.5em; /* Maintain the height */
}
#chatboxInput {
height: 3.35em;
width: 37.3em; /* Keep the width the same */
background-color: #36393f; /* Keep the color the same */
border: 0.15em solid #000;
border-radius: 0 0 0.3125em 0.3125em; /* Round the border */
padding-bottom: 1.5em;
box-sizing: border-box;
margin: 0 auto;
display: flex;
}
.input-group {
display: flex;
justify-content: space-between;
width: 31.25em;
margin: 0 auto;
}
button[type='submit'] {
display: inline-block;
width: 4em;
height: 3em;
border: 0.125em solid #000;
background-color: #36393f;
border-radius: 0.3125em;
}
#chatboxTranscript {
width: 31.25em;
/* padding: 0em; */
background-color: #36393f;
color: #fff;
display: flex;
border: 0.125em solid #000; /* Increase border width */
border-radius: 0.3125em 0.3125em 0 0; /* Round the border */
box-sizing: border-box;
margin: 0 auto;
height: 12.5em; /* Maintain the height */
}
#chatboxInput {
top: -0.125em;
height: 3.35em;
left: -2.2em;
width: 37.3em; /* Keep the width the same */
background-color: #36393f; /* Keep the color the same */
border: 0.15em solid #000;
border-radius: 0 0 0.3125em 0.3125em; /* Round the border */
padding-bottom: 1.5em;
box-sizing: border-box;
margin: 0 auto;
display: flex;
/* border-top: none; */
position: relative;
}
.input-group {
display: flex;
justify-content: space-between;
}
button[type="submit"] {
position: fixed;
display: inline-block;
width: 4em;
top: -0.1em;
height: 3em;
margin: 0 -2em;
border: 0.125em solid #000;
background-color: #36393f;
border-radius: 0.3125em;
}
I edited position of button from "reletive" to "fixed". It will work in page.
This is what it looks at 100% Looks good at 100%. but as soon you zoom in/out the element shifts slightly This is what it looks like at 125%
Here is the css for the "blue dropdown" element
.blueDropdown {
position: absolute;
width: 20px;
min-height: 100%;
background: #3075b5;
border-radius: 0px 4px 4px 0px;
}
and here is the css for the border that i want to match it with
.dropdownBorder {
box-sizing: border-box;
position: relative;
top: 24px;
width: 70%;
min-height: 100%;
background: #fafafa;
border: 2px solid #3075b5;
border-radius: 10px;
left: 395px;
cursor: pointer;
text-decoration: none;
background-color: transparent;
z-index: 1;
display: flex;
justify-content: end;
}
Here is the html
<Row className="dropdownBorder" style={{paddingRight: "0px"}}>
<div className="blueDropdown"></div>
</Row>
So what causes it to shift in Chrome/Edge but not in Firefox?
I'm using this dark mode toggle that affect all the text plus the background color and when I click on it the colors they switch. But I have a problem with the circles that I've designed. I'd like the dark mode affect the background color of them, having the background inside the circles "lime" on the black background and viceversa. Here's the code and the link to the page:
https://civitonia.com/26993899
HTML:
<div class="grid">
<div class="cell">
<div class="inner">
<div class="circle" style="background-image:url('https://freight.cargo.site/t/original/i/655f74e74d3b88cc9d367ba8cccd79680c3837a84a547f9e03b6f39981f424e0/3.png');"></div>
<div class="caption">
<h3>Chiara Bersani <br> Marta Montanini</h3>
</div>
</div>
</div>
DARK MODE CSS:
.colorOuterSVG {
color: black;
margin-top: 2em;
padding: 0.5em
}
.colorOuterSVG .dark { display: none }
.colorOuterSVG .light { display: block }
.dark-mode .colorOuterSVG {color:#d9ff76!important; }
.dark-mode .colorOuterSVG .dark { display: block }
.dark-mode .colorOuterSVG .light { display: none }
.colorSVG { display: block }
.colorSVG path { fill: currentColor }
.dark-mode {
background-color: black!important;
color: #d9ff76!important;
}
.dark-mode button {
color: black!important;
background-color: #d9ff76;
padding: 5px 5px 5px 5px;
border-radius: 15px;
border: solid 1px #000000;
cursor: pointer;
position: absolute;
bottom: 10px;
}
THE CIRCLES MADE WITH CSS:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.grid {
display: flex;
flex-wrap: wrap;
max-width: 980px;
width: 100%;
margin: auto;
padding-top: 5%;
padding-bottom: 5%;
}
.cell {
flex-basis: 33.3%;
display: flex;
justify-content: center;
align-items: center;
align-items : flex-start
}
.cell:before {
padding-bottom: 100%;
display: block;
content: '';
}
.circle {
width: 250px;
height: 250px;
border: 0.5px solid;
border-radius: 50%;
background-position: center;
background-size: contain;
background-repeat: no-repeat;
box-shadow: 0px 0px 15px 0px;
overflow: hidden;
margin: 0 auto 1em;
background-color: #d9ff76!important;
}
.circle img {
width: 100%;
position: relative;
height: 100%;
}
h3 {
text-align: center;
}
.inner {
text-align: start;
padding-bottom: 30%;
}
Right now I've set up a background color for the circles and if I take it away the background will stay lime on lime and black on black!
Add this css code for dark mode :
.dark-mode .circle {
background-color: #000 !important;
}
I have a fixed toolbar having the buttons btn1, btn2, btn3 (the toolbar is set to display: flex, justify-content: space-between and position: fixed), but unfortunately when the content of the page is too long that makes the scrollbar to appear, the scrollbar overrides a part of btn3. What should I do to make the scrollbar take its own space when it appears? Or make the toolbar automatically stretch a bit to leave some space for the scrollbar?
Without scrollbar
With scrollbar (the three dots are behind the scrollbar)
.Toolbar {
height: 65px;
background-color: rgb(48, 48, 48);
color: white;
width: 100vw;
position: fixed;
box-shadow: 0px 2px 6px -2px rgb(138, 138, 138);
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: space-between;
}
.WholePage {
height: 1000px;
}
<div class="WholePage">
<header class="Toolbar">
<div>btn1</div>
<div>btn2</div>
<nav>btn3</nav>
</header>
</div>
Forcing the width to 100vw pushes it behind the scrollbar. Use 100% instead.
.Toolbar {
height: 65px;
background-color: rgb(48, 48, 48);
color: white;
width: 100%;
position: fixed;
box-shadow: 0px 2px 6px -2px rgb(138, 138, 138);
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: space-between;
}
.WholePage {
height: 1000px;
}
header>* {
border: 2px solid pink;
padding: 3px;
}
<div class="WholePage">
<header class="Toolbar">
<div>btn1</div>
<div>btn2</div>
<nav>btn3</nav>
</header>
</div>
I think your issue could come from the the box-sizing.
Try box sizing: box-sizing: border-box; for those buttons. I add .btn as my example for those three buttons.
.btn {
box-sizing: border-box;
}
For the detail of the box-sizing, please check it as https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing#box_sizes_with_content-box_and_border-box.
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.toolbar {
background-color: rgb(48, 48, 48);
color: white;
box-shadow: 0px 2px 6px -2px rgb(138, 138, 138);
height: 100px;
width: 100vw;
position: fixed;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: space-between;
}
.toolbar div {
display: flex;
border: 1px solid red;
}
.whole-page {
height: 2000px;
}
<div class="whole-page">
<header class="toolbar">
<div>btn1</div>
<div>btn2</div>
<div>btn3</div>
</header>
</div>
Title is a bit of a mouthful. I've just started with CSS and am trying to achieve the effect a text overlay while the image is still transparent behind the text.
Below is what I've managed to achieve by snipping together various bits of code I've found. I am struggling to get the dark overlay the same size as the image. I haven't used any margin or padding on the overlay or image so have no clue why it's happening. I've also tried several ways to align the text so it sits vertically in the middle but have had no such luck.
.image-container {
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
}
.border {
border-radius: 50%;
}
.image-container .after {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
display: none;
color: #FFF;
border-radius: 50%;
}
.image-container:hover .after {
display: block;
background: rgba(0, 0, 0, .6);
border-radius: 50%;
}
#title {
background: url('https://bopepor.es/wp-content/uploads/2018/08/Logo-200x200PX.png');
background-size: cover;
color: #fff;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
padding: 0;
display: flex;
}
h1 {
font-size: 80px;
font-family: sans-serif;
text-align: center;
text-shadow: 0 0 1px rgba(0, 0, 0, .1);
margin: 0;
padding: 0;
letter-spacing: -1px;
line-height: 0.8;
}
<div class="image-container">
<img src="https://bopepor.es/wp-content/uploads/2018/08/Logo-200x200PX.png" class='border' />
<div class="after">
<div id="title">
<h1><b>ONE<br>TWO</b></h1>
</div>
</div>
</div>
For the first issue You will not able to center the overlay on to the image because the image isn't actually 200px x 200px because there are transparent pixels around the image. so first crop the transparent pixels around the image and get it's real size. Then replace the 200px size in the css below to the appropriate size.
I have corrected your code snippet to be able to center the text by adding display: flex and align-content: center (for vertical alignment) and justify-content: center(for horizontal alignment),
I have also added overflow: hidden to the .image-container .after to prevent overflowed text and changed the text size to 60px for better visibility.
.image-container {
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
}
.image-container .after {
position: absolute;
display: none;
left: 0;
bottom: 0;
overflow: hidden;
color: #FFF;
}
.image-container:hover .after {
display: flex;
background: rgba(0, 0, 0, 0.6);
border-radius: 50%;
border-width: 0px;
width: 200px;
height: 200px;
}
#title {
background: url('https://bopepor.es/wp-content/uploads/2018/08/Logo-200x200PX.png');
background-size: cover;
color: #fff;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
padding: 0;
display: flex;
align-content: center;
justify-content: center;
width: 100%;
}
h1 {
font-size: 60px;
font-family: sans-serif;
text-align: center;
text-shadow: 0 0 1px rgba(0, 0, 0, .1);
margin: 0;
padding: 0;
display: flex;
align-items: center;
letter-spacing: -1px;
line-height: 0.8;
}
<div class="image-container">
<img src="https://bopepor.es/wp-content/uploads/2018/08/Logo-200x200PX.png" class='border' />
<div class="after">
<div id="title">
<h1><b>ONE<br>TWO</b></h1>
</div>
</div>
</div>