Make body width correspond to divs existence - html

I created a horizontal timeline with dots for each information, however if enough "dots/information" are created the body width needs to be able to expand to make the dots continue on the same line of the timeline instead of moving down a line because of the limited width of the page.
I tried giving the body a larger width, it does fix the problem but I would much rather have the width working dynamically to correspond with the timeline's dots. So if there is only a few dots on the timeline, the page wont have to be any wider, but if there is a lot then the page width should expand.
Here is the css of my timeline.
The time is implemented with PHP and HTML. The dots are created through a simple php sql loop.
div#timeline3 {
background-color: lightblue;
margin-top: 150px;
height: 12px;
width: 100%;
top: 0px;
position: relative;
}
div#timeline3 .inside {
position: absolute;
height: 4px;
background-color: #fff;
width: 0%;
top: 3px;
left: 0;
}
div#timeline3 .dot {
z-index: 99;
transition: 0.3s ease-in-out;
width: 52px;
height: 52px;
border-radius: 50%;
position: relative;
top: -20px;
margin-left: 220px;
float: left;
text-align: center;
cursor: pointer;
-webkit-box-shadow: 8px 0px 05.3px -8px black, -8px 0px 05.3px -8px black;
-moz-box-shadow: 8px 0px 05.3px -8px black, -8px 0px 05.3px -8px black;
box-shadow: 8px 0px 05.3px -8px black, -8px 0px 05.3px -8px black;
}
div#timeline3 .dot:nth-child(1) {
left: 1%;
background-color: lightblue;
}

Related

How to add box-shadow css property only to the bottom for the div element using css?

i want to add box-shadow only to the bottom of the div element using css.
below is the picture of what i am trying to do?
i want to get the line marked in red.
below is my code,
<div class="wrapper">
<div class="container"> //this needs box-shadow bottom
<span class="text">sometext</span>
<div class="description">some big description</div>
</div>
</div>
.wrapper {
position: absolute;
bottom: 32px;
width: 316px;
height: 225px;
background: white;
box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.29);
border-radius: 16px;
display: flex;
flex-direction: column;
opacity: 1;
}
.container {
height: 101px;
width: 316px;
padding-top: 16px;
padding-left: 16px;
border-radius: 16px 16px 0 0;
box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.29); //this adds boxshadow to all sides
}
.description {
height: 42px;
width: 289px;
margin-top: 8px;
color: black;
display: flex;
font-size: 12px;
font-weight: 400;
margin-bottom: 16px;
`;
As you see the container class adds boxshadow to all sides. i want to add only for the bottom how can i do it? could someone help me with this. thanks.
Try making your .container CSS like this:
.container {
height: 101px;
width: 316px;
padding-top: 16px;
padding-left: 16px;
border-radius: 16px 16px 0 0;
-webkit-box-shadow: 0px 10px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 10px 5px 0px rgba(0,0,0,0.75);
box-shadow: 0px 10px 5px 0px rgba(0,0,0,0.75);
}
Let me know how it goes.

Playing with CSS shapes: How to make a custom ICON using pure HTML and CSS

Currently, I am playing with HTML and CSS and I wanted to make a icon from this image
the image is somewhat like that. I tried adding different shapes of ovals and circles inside the bigger circle but it did not work. For the shaded part, I used a box-shadow in styling it. There are already too many divs in my sample icon. I just want to have it simple and readable.
Here is my HTML structure:
<link rel="stylesheet" href="style.css">
<div class="cont">
<div class="icon2">
<div class="inner-circle"></div>
</div>
</div>
and here is my CSS:
.cont {
width: 190px;
height: 190px;
padding: 20px;
}
.icon2 {
position: relative;
border: 2px solid #353332;
width: 187px;
height: 184px;
border-radius: 50%;
background-color: #fff;
box-shadow: inset 20px 35px #1CAEE3;
transform: rotate(177deg);
}
.inner-circle {
border: 7px solid #353332;
width: 120px;
height: 183px;
background-color: #fff;
border-radius: 50% 50% 50% 49% / 60% 52% 40% 40%;
transform: rotate(240deg);
display: block;
margin: 6px 0px 4px 35px;
border-top: 0;
border-bottom: 0;
border-left: 0;
}
Can you explain me this and how can I come up with a solution to my problem? I'm stuck for hours and I just wanted to try it with pure HTML and CSS and not using photoshop.
You can easily do this with one element and radial-gradient. Simply adjust the percentage used inside the gradient to control the shape:
.box {
width:150px;
height:150px;
border-radius:50%;
border:4px solid;
background:
radial-gradient(circle at top left,transparent 59.4%,black 60% calc(60% + 4px),orange calc(60% + 5px));
}
<div class="box"></div>
You can also use box-shadow ;)
https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread radii, and color.
demo aside your image:
div {
border: solid 6px;
display: inline-flex;
height: 200px;
width: 200px;
border-radius: 50%;
box-shadow: inset -50px -70px 1px -30px rgb(255, 127, 39), inset -56px -77px 1px -33px;
}
code {
font-size: 30px;
color: green;
margin: auto;
font-weight: bold;
}
div,
img {
vertical-align: middle;
}
<img src="https://i.stack.imgur.com/HRpQY.png">
<div><code>box-shadow</code></div>
another example :
div {
float:left;
height: 180px;
width: 180px;
margin: 1em;
box-sizing: border-box;
padding: 25px;
background: #F4E5D9;
box-shadow: inset -40px -40px 3px -20px #C5824D, inset 40px 40px 3px -20px #EABD9A, inset 0 0 2px 30px #AD6026, inset 0 0 0px 32px #705642, inset 0 -55px 3px 10px #705B4B, inset 0 55px 3px 10px #705B4B, 0 0 3px 2px #705B4B, 0 0 3px 4px #665447, 0 0 3px 7px #3F332A, 0 0 3px 9px #705642, 88px 90px 1px -86px gray, 87px 85px 2px -82px #F2C232, 85px 95px 2px -82px #A30700, 92px 92px 2px -82px #C5824D, 88px 90px 10px -70px white;
border-radius:50%;
display:flex;
flex-direction:column;
justify-content:center;text-align:center;
}
div + div {border-radius:4em /50%;
<div>
<p>inset shadow </p>
<p>border-radius </p>
<p>decreased shadow </p>
</div>
<div>
<p>inset shadow </p>
<p>border-radius </p>
<p>decreased shadow </p>
</div>
you may also draw citrus slices https://codepen.io/gcyrillus/pen/wutEK .
but SVG would be at best here ;)
You could make use of a pseudo element and have an overflow:hidden to hide the rest of the pseudo element's parts that fall outside of the div's 'outer circle'
div {
height: 200px;
width: 200px;
overflow: hidden;
border: 5px solid black;
background:orange;
border-radius: 50%;
position: relative;
}
div:after {
content: "";
position: absolute;
height: 100%;
width: 200%;
border: inherit;
border-radius: 50%;
background: white;
top: -20%;
left: -100%;
}
<div></div>

Push top half of image outside of card

I am attempting to create the following design in Ionic:
Currently, I am specifically trying to push the top half of an image past the top of the card and have the image be about 80% of the width of the card.
How can I push the top half of the image outside of the card?
I have created a StackBlitz for this issue.
Edit: I have been able to make the image protrude the top half of the card but the image is overlapping text and other images. How can I push the card down where the top half contains the bottom half of the image and the bottom half contains the additional text, images, etc.?
Here is my CSS:
.card {
margin-left: 30px;
margin-right: 30px;
width: auto;
border-radius: 8px;
position: relative;
display: block;
margin-top: 100px;
overflow: visible;
div {
position: absolute;
top: -95px;
width: 100%;
text-align: center;
}
img:not(.castImg) {
width: 80%;
border-radius: 8px;
-webkit-box-shadow: 0 8px 6px -6px black;
-moz-box-shadow: 0 8px 6px -6px black;
box-shadow: 0 8px 6px -6px black;
display: block;
margin: -100px auto 0;
}
}
looking at the code here Made 2 changes in the home.scss file... play around with 17% which is an arbitrary number on both places
.card {
margin-left: 30px;
margin-right: 30px;
width: auto;
border-radius: 8px;
margin-top: 17%; /* Change 1a */
overflow: visible; /* Change 1b */
img:not(.castImg) {
width: 80%;
margin: auto;
margin-top: -17%; /* Change 2 */
border-radius: 8px;
-webkit-box-shadow: 0 8px 6px -6px black;
-moz-box-shadow: 0 8px 6px -6px black;
box-shadow: 0 8px 6px -6px black;
}
ion-card-title {
font-weight: bold;
text-align: center;
}
}

keep children div inside of parent div

Okay, hi, I feel like this is a very silly question, and I've found a lot of questions like it, but none of the answers seemed to work for me.
My issue is that have one div (taskbar) and inside of it another div (taskbar-bar) and I want taskbar-bar to stay within taskbar. I tried putting position on absolute and relative and it didn't seem to work at all, it's always underneath the taskbar div. I could push it up with top, but I don't feel like that's the way to go right now. I don't know, though, I'm honestly very new to CSS and HTML and still am learning.
Here's a jsfiddle of my code: https://jsfiddle.net/5zghzczs/3/
.taskbar {
width: 100%;
height: 40px;
box-shadow: 0px 1px 0px 0px #C2C5CA inset, 0px 2px 0px 0px #FFF inset;
background-color: #C2C5CA;
position: absolute;
left: 0;
bottom: 0;
}
#taskbar-start {
margin-top: 4px;
margin-bottom: 2px;
margin-left: 2px;
width: 90px;
height: 33px;
background-color: #C2C5CA;
cursor: pointer;
}
.taskbar-start-inactive {
box-shadow: -1px -1px 0px 0px #000 inset, 1px 1px 0px 0px #FFF inset, -2px -2px 0px 0px #868A8E inset;
}
.taskbar-start-active {
box-shadow: -1px -1px 0px 0px #FFF inset, 1px 1px 0px 0px #000 inset, 2px 2px 0px 0px #868A8E inset;
}
.taskbar-start-frame-active {
margin-top: 2px;
margin-left: 2px;
width: 84px;
height: 27px;
border-style: dotted;
border-width: 1px;
position: absolute;
}
.taskbar-start-logo {
margin-top: 6px;
margin-left: 3px;
width: auto;
height: 20px;
-webkit-user-select: none;
}
.taskbar-start-text {
margin-top: 10px;
margin-left: 5px;
display: inline;
font-size: 12px;
letter-spacing: -2px;
-webkit-user-select: none;
font-family: "Press Start 2P";
position: absolute;
}
.taskbar-bar {
height: 35px;
width: 2px;
background: green;
margin-left: 100px;
}
<div class="taskbar">
<div id="taskbar-start" class="taskbar-start-inactive">
<div id="taskbar-start-frame">
<img class="taskbar-start-logo" src="img/logo.png" />
<div class="taskbar-start-text">Start</div>
</div>
</div>
<div class="taskbar-bar"></div>
Your problem is that you are using margin-left, which is trying to give a margin in between one div and the other. Here is a new JSFiddle where I set the position to absolute, changed the margin-left to left, and added top: 0px; to set it to be at the top (overlaying the other div).
.taskbar-bar {
position: absolute;
top: 4px;
left: 100px;
height: 35px;
width: 2px;
background: green;
}
I think the best way to do this is to make the parent a flexbox container.
This will position all children in a row.
display: flex;
See https://jsfiddle.net/5zghzczs/7/
Read more about flexbox here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Change the "display" of taskbar-start and taskbar-bar to "inline-block"
.taskbar-start, .taskbar-start {
display: inline-block;
}
fit-content worked for me like a charm when dynamic text was forcing my modal wider.
max-width: fit-content;
More on fit-content https://developer.mozilla.org/en-US/docs/Web/CSS/fit-content

Background color and styles does not appear correctly

Please take a look at my site http://kaniamea.com/2/ I am trying to get the contentarea appear correctly behind the three Attractions boxes. My css is:
#attractions {
width: 290px;
height: auto;
display: block;
padding-right: 20px;
float: left;
}
and this is the code of my main container:
#main {
margin: 10px auto 0px;
width: 950px;
max-width:100%;
background: none repeat scroll 0% 0% #FBFBFB;
padding: 10px;
background-color: #FFF;
border: 2px solid #FFF;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
-webkit-box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.75);
box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.75);
}
When I remove float: left; from #attractions and replace it it with display: inline-block; it works but I need to figure out another solution with float: left; so this will float correctly on mobile. Is there another way to make the contentarea styles appear behind the boxes?