I'm trying to display 2 images in a line below a line of text, but they show up in the same line. I tried using the "clear: both" property and "display: block" property in the CSS style for the images. What am I missing?
I included a screenshot of what it looks like as well as the relevant section of the HTML code and the complete CSS stylesheet. The "media" class is what I am using for the images. They are showing on the same line as the section under the "Contacts" div.
screenshot of website here
body {
background-color: #63a4ff;
background-image: linear-gradient(315deg, #63a4ff 0%, #83eaf1 74%);
}
.fadeline {
background-color: white;
margin: 25px 20%;
width: 60%;
height: 1px;
}
.fadeline.white {
background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
}
.fadeline.black {
background: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
.row {
background-color: white;
margin: 0% 15% 0% 15%;
padding-bottom: 15%;
padding-top: 50px;
color: #586E95;
}
.header {
text-align: center;
padding-left: 40%;
}
#about {
text-align: center;
}
p {
margin: 0 auto;
display: block;
clear: both;
}
.example {
margin: 0 auto;
background-color: white;
border: 1px solid black;
border-radius: 10%;
outline: none;
width: 20%;
}
a,
a:hover {
text-decoration: none;
display: block;
}
img {
max-height: 90%;
max-width: 90%;
}
.media {
height: 55px;
width: 55px;
display: block;
margin: 0 auto;
}
<div id="contact" class="row text-center">
<h1 class="header">Contact</h1>
<div class="fadeline black"></div>
<p> Want to connect? Reach out with Facebook or LinkedIn.</p>
<div class='media'>
<a href='https://www.facebook.com/siddharth.gampa/'><img src='https://facebookbrand.com/wp-content/uploads/2019/04/f_logo_RGB-Hex-Blue_512.png?w=512&h=512'></a>
</div>
<div class='media'>
<a href='https://www.linkedin.com/in/siddharth-gampa/'><img src='https://image.flaticon.com/icons/svg/174/174857.svg'></a>
</div>
</div>
If you place both images in one div with the class .media then set that div to display: flex that should work.
Check out the example code below by clicking the Run code snippet
body {
background-color: #63a4ff;
background-image: linear-gradient(315deg, #63a4ff 0%, #83eaf1 74%);
}
.row {
display: flex;
flex-direction: column;
background-color: white;
margin: 0 15%;
padding: 50px 0;
color: #586E95;
}
.text-center {
text-align: center;
}
.heading {
text-align: center;
}
.fadeline {
background-color: white;
margin: 25px 20%;
width: 60%;
height: 1px;
}
.fadeline.white {
background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
}
.fadeline.black {
background: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
.media {
display: flex;
justify-content: center;
width: 100%;
}
a img {
width: 40px;
margin: 0 10px;
}
<div id="contact" class="row text-center">
<h1 class="heading">Contact</h1>
<div class="fadeline black"></div>
<p> Want to connect? Reach out with Facebook or LinkedIn.</p>
<div class='media'>
<a href='https://www.facebook.com/siddharth.gampa/'>
<img src='https://facebookbrand.com/wp-content/uploads/2019/04/f_logo_RGB-Hex-Blue_512.png?w=512&h=512'>
</a>
<a href='https://www.linkedin.com/in/siddharth-gampa/'>
<img src='https://image.flaticon.com/icons/svg/174/174857.svg'>
</a>
</div>
</div>
It looks like they're not below the text because they're in the same div with the row class.
Put them in a div below the row and it should work
Add a class to both images. For example
Class="img-1"
And
Class="img-2"
Make their position relative then push one of the images to the right. It may take some fiddling to get the locations correct
Related
I'm trying to get a little complicated result in CSS. See potentially impossible.
Let's imagine the following code:
<div class="div1">
<div class="div2">
<div class="div3">
<div class="div4"></div>
Hello World
</div>
</div>
</div>
div {
box-sizing: border-box;
outline: 1px solid rgba(0, 0, 0, 0.5);
}
.div1 {
background: rgba(255, 0, 0, 0.5);
}
.div2 {
width: 800px;
margin: 0 auto;
display: flex;
background: rgba(0, 255, 0, 0.5);
}
.div3 {
position: relative;
background: rgba(0, 0, 255, 0.5);
}
.div4 {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(255, 0, 255, 0.5);
}
I would like the left edge of .div4 to touch the left edge of .div1 and the right edge of .div4 to touch the right edge of .div3.
Current result
If position: relative; is given to .div1
Expected result
If you have another solution to achieve the same result, I'm interested!
https://jsfiddle.net/610xL7j4/78/
Maybe I am wrong but why, you don't want to do it with 3 div elements?
<div class="div1">
<div class="div2">
<div class="div3">
Hello world
</div>
</div>
</div>
div {
box-sizing: border-box;
outline: 1px solid rgba(0, 0, 0, 0.5);
}
.div1 {
background: rgba(255, 0, 0, 0.5);
display: flex;
justify-content: center;
}
.div2 {
width: 800px;
margin: 0 auto;
background: rgba(0, 255, 0, 0.5);
}
And when you have this done, in div3 put the text hello world and give to div3 the background color whatever you want.
.div3 {
background-color: purple;
}
I would do it bit differently with css:
.div1{
background: rgba(255, 0, 0, 0.5);
display: flex;
justify-content: center;
border: 1px solid black
}
.div2 {
width: 800px;
margin: 0 auto;
border-left: 1px solid black;
border-right: 1px solid black;
background: rgba(0, 255, 0, 0.5);
}
.div3 {
background-color: purple;
border-right: 1px solid black;
}
I think this should do the trick and with this, the borders everywhere would be exactly 1 px not stacking on each other.
I am trying to make a progress bar as is shown here in the about section however I am just lost.
I can make a bar and a box but neither look anywhere near as good as that and I cannot for the life of me get them to be beside each other with equal height. I just keep getting something along the lines of
What I am trying to achieve in case website goes down:
.myskills {
width: 45vw;
height: 100%;
background: red;
margin: 1em;
}
.skillbarContainer {
display: flex;
justify-content: center;
height: 2vh;
}
.skillName {
background-color: blue;
width: 5vw;
float: left;
height: 100%;
font-size: 2em;
}
.meter {
float: left;
width: 80%;
height: 100%;
/* Can be anything */
position: relative;
background: #555;
padding: 3px;
}
.meter>span {
display: block;
height: 100%;
background-color: hotpink;
box-shadow: inset 0 2px 9px rgba(255, 255, 255, 0.3), inset 0 -2px 6px rgba(0, 0, 0, 0.4);
position: relative;
overflow: hidden;
}
<div class="myskills">
<div class="skillbarContainer">
<div class="skillName">HTML</div>
<div class="meter">
<span style="width: 80%"></span>
</div>
</div>
</div>
This code below will give you the percentage sign on the right of the percentage bar. A lot of this is purely layering with hmtl/css.
Here are some links for layering and z-index:
https://www.tutorialspoint.com/css/css_layers.htm#:~:text=The%20CSS%20layers%20refer%20to,element%20should%20come%20at%20bottom.
https://www.w3schools.com/cssref/pr_pos_z-index.asp
https://css-tricks.com/almanac/properties/z/z-index/
.myskills {
width: 90%%;
background: red;
margin: 1em;
}
.skillbarContainer {
display: flex;
}
.skillLevel{
right: 0;
font-size: 1.7em;
position: absolute;
}
.skillName {
background-color: rgb(77, 252, 208);
float: left;
font-size: 2em;
}
.meter {
float: left;
width: 100%;
/* Can be anything */
position: relative;
background: rgb(218, 217, 217);
padding: 3px;
}
.meter>span {
display: block;
height: 100%;
background-color: rgb(31, 134, 117);
box-shadow: inset 0 2px 9px rgba(255, 255, 255, 0.3), inset 0 -2px 6px rgba(0, 0, 0, 0.4);
}
<div class="myskills">
<div class="skillbarContainer">
<div class="skillName">HTML</div>
<div class="meter">
<span style="width: 80%"><span class="skillLevel">90%</span></span>
</div>
</div>
</div>
Well, IMO you should use less vh and vw. Your font simply defines the height and the width of the text part. By removing them, you get something as you want as I understood (I also removed useless properties) :
.myskills {
width: 45vw;
background: red;
margin: 1em;
}
.skillbarContainer {
display: flex;
}
.skillName {
background-color: blue;
font-size: 2em;
}
.meter {
float: left;
width: 100%;
/* Can be anything */
position: relative;
background: #555;
padding: 3px;
}
.meter>span {
display: block;
height: 100%;
background-color: hotpink;
box-shadow: inset 0 2px 9px rgba(255, 255, 255, 0.3), inset 0 -2px 6px rgba(0, 0, 0, 0.4);
}
<div class="myskills">
<div class="skillbarContainer">
<div class="skillName">HTML</div>
<div class="meter">
<span style="width: 80%"></span>
</div>
</div>
</div>
Now, if it was my progress bar I'd use flex instead of width for .meter, I'd take a smaller font size and put padding to the text :
.myskills {
width: 45vw;
background: red;
margin: 1em;
}
.skillbarContainer {
display: flex;
}
.skillName {
background-color: blue;
font-size: 18px;
padding: 3px 10px;
}
.meter {
float: left;
flex: 1;
/* Can be anything */
position: relative;
background: #555;
padding: 3px;
}
.meter>span {
display: block;
height: 100%;
background-color: hotpink;
box-shadow: inset 0 2px 9px rgba(255, 255, 255, 0.3), inset 0 -2px 6px rgba(0, 0, 0, 0.4);
}
<div class="myskills">
<div class="skillbarContainer">
<div class="skillName">HTML</div>
<div class="meter">
<span style="width: 80%"></span>
</div>
</div>
</div>
I'm trying to get a input slider within another parent div. The
desired result looks like this:
The problem is when I try this the input slider gets a huge width, and
the height is messed up aswel.
I made Fiddle:
.wrapper {
display: inline-block;
width: 100%;
max-width: 100px;
background: #353434;
color: rgba(255, 255, 255, 0.9);
box-shadow: inset 0px 0px 4px 0px rgba(0, 0, 0, 0.75);
font-family: 'Raleway', 'Helvetica Neue', 'Helvetica', 'Arial'
}
.wrapper-header {
display: flex;
flex-flow: row nowrap;
justify-content: center;
padding: .5rem;
}
.wrapper-middle {
display: flex;
justify-content: center;
align-items: center;
}
.wrapper-end {
display: flex;
flex-flow: row nowrap;
justify-content: center;
height: 340px;
padding-top: 1rem;
padding-bottom: 1rem;
}
.slider-value {
min-width: 24px;
padding: .25rem;
border-radius: 2px;
color: #1fcc1f;
background: #333;
box-shadow: inset 0 0 3px 3px rgba(0, 0, 0, 0.5);
font-family: 'VT323', monospace;
text-align: center;
}
.button {
padding: .55rem;
border-radius: 2px;
background: linear-gradient(to bottom, #4f4f4f 0%, #0e0e0e 100%);
box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.5);
}
.wrapper-end-left {
height: 100%;
background: red;
}
.wrapper-end-right {
height: 100%;
background: blue;
}
[type='range'] {
-webkit-appearance: none; /* Hides the slider so that custom slider can be made */
margin: 0;
padding: 0;
width: 30rem;
height: 1.5em;
transform: rotate(-90deg);
background: transparent;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
box-sizing: border-box;
border: none;
width: 1.5em; height: 1.5em;
border-radius: 50%;
background: #f90;
}
input[type=range]::-webkit-slider-runnable-track {
box-sizing: border-box;
border: none;
margin: 0;
padding: 0;
width: 100%; height: 100%;
background: #ccc;
}
<div class="wrapper">
<div class="wrapper-header">
<div class="button">
x
</div>
<div class="button">
x
</div>
</div>
<div class="wrapper-middle">
<div class="slider-value">
1
</div>
</div>
<div class="wrapper-end">
<div class="wrapper-end-left">
<input type="range">
</div>
<div class="wrapper-end-right">
two
</div>
</div>
</div>
Does someone know why this is happening?
Already read a lot here about input sliders but can't fix it.
https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/
https://codepen.io/freoted/pen/WGvxmN
https://jsfiddle.net/rwaldron/XukVc/
It is a little hacky but it resembles the desired layout now slightly closer - not tested to see how this would fare at different locations on the page or at different sizes. one of the key things that changed the layout was setting the transform-origin and tweaking the location with translate3d
document.addEventListener('DOMContentLoaded',(e)=>{
document.querySelector('[type="range"]').addEventListener('change',(e)=>{
document.querySelector('div.slider-value').textContent=e.target.value > 0 ? e.target.value : e.target.value * -1;
});
});
.wrapper {
display: inline-block;
width: 100%;
max-width: 100px;
background: #353434;
color: rgba(255, 255, 255, 0.9);
box-shadow: inset 0px 0px 4px 0px rgba(0, 0, 0, 0.75);
font-family: 'Raleway', 'Helvetica Neue', 'Helvetica', 'Arial'
}
.wrapper,.wrapper *{
box-sizing: border-box;
}
.wrapper-header {
display: flex;
flex-flow: row nowrap;
justify-content: center;
padding: .5rem;
}
.wrapper-middle {
display: flex;
justify-content: center;
align-items: center;
}
.wrapper-end {
display: flex;
flex-flow: row nowrap;
justify-content: center;
height: 340px;
padding-top: 1rem;
padding-bottom: 1rem;
}
.slider-value {
min-width: 24px;
padding: .25rem;
border-radius: 2px;
color: #1fcc1f;
background: #333;
box-shadow: inset 0 0 3px 3px rgba(0, 0, 0, 0.5);
font-family: 'VT323', monospace;
text-align: center;
}
.button {
padding:0.55rem;
border-radius:2px;
background: linear-gradient(to bottom, #4f4f4f 0%, #0e0e0e 100%);
box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.5);
}
.wrapper-end-left {
height: 100%;
padding:0;
margin:0 1.25rem 0 0;
display:flex;
flex-direction:column;
flex-wrap:no-wrap;
align-content:center;
justify-content:stretch;
}
.wrapper-end-right {
height:100%;
width:0.75rem!important;
background:linear-gradient(0deg, rgba(13,60,2,1) 0%, rgba(57,241,17,1) 79%, rgba(245,157,63,1) 92%, rgba(255,0,0,1) 100%);
}
.wrapper-end-left,
.wrapper-end-right{
width:2rem;
}
[type='range'] {
-webkit-appearance:none;
margin:0;
padding:0;
flex:1;
height:1.5rem;
width:19.2rem;
transform-origin:5% 50%;
transform:rotate(-90deg) translate3d( -8.6rem, -0.25rem, 0 );
background:transparent;
outline:0;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance:none;
border:none;
width:1.5em;
height:1.5em;
border-radius:50%;
background:black;
border:2px solid silver;
margin:-0.35rem 0 0 0;
}
input[type=range]::-webkit-slider-runnable-track {
box-sizing:border-box;
border:none;
margin:0;
padding:0;
height:0.5rem;
flex:1;
background:#ccc;
}
<div class="wrapper">
<div class="wrapper-header">
<div class="button">x</div>
<div class="button">x</div>
</div>
<div class="wrapper-middle">
<div class="slider-value">0</div>
</div>
<div class="wrapper-end">
<div class="wrapper-end-left"><input type="range" step=3 min=-60 max=12 value=0 /></div>
<div class="wrapper-end-right"> </div>
</div>
</div>
I am trying to make an A tag fill the parent TD element. However, no matter what I try it doesn't seem to work.
I have viewed many various other Stack Overflow pages and they all state to do
child-element{
display: block;
width: 100%;
}
But this has not seemed to work in my case.
html {
font-family: "Times New Roman", Times, serif;
color: white;
}
#wrapper {
background-color: black;
background: #50a3a2;
background: -webkit-linear-gradient(top left, #50a3a2 0%, #53e3a6 100%);
background: linear-gradient(to bottom right, #50a3a2 0%, #53e3a6 100%);
}
a {
color: white;
text-decoration: none;
background-color: none;
cursor: pointer;
}
#wrapper,
#header,
#main {
padding: 10px 15px;
margin: 0 auto 10px auto;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
#header {
min-width: 40vw;
max-width: 50vw;
}
#main {
min-height: 65vh;
}
.nav-link {
float: left;
padding: 10px 15px;
margin: 0 5px 0 5px;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
.nav-link:hover {
background-color: rgba(255, 255, 255, 0.4);
}
.nav-link a {
display: block;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.3);
}
<body>
<div id="wrapper">
<div id="header">
<table align="center">
<td class="nav-link">Main</td>
<td class="nav-link">Test</td>
<td class="nav-link">FAQ</td>
</table>
</div>
<div id="main">
<h1 style="line-height: 0%">Header</h1>
<p style="line-height: 0%; font-size: 1vw">_________________________________________________________________________________________________________</p>
<br>
<br>
</div>
</div>
</body>
If you would like to see this displayed you can view here: https://jsfiddle.net/wverhe/8gcypffm/
Remove the padding from .nav-link and add it to the .nav-link a. You can also remove the width and height from links since they will get resized from the padding.
html {
font-family: "Times New Roman", Times, serif;
color: white;
}
#wrapper {
background-color: black;
background: #50a3a2;
background: -webkit-linear-gradient(top left, #50a3a2 0%, #53e3a6 100%);
background: linear-gradient(to bottom right, #50a3a2 0%, #53e3a6 100%);
}
a {
color: white;
text-decoration: none;
background-color: none;
cursor: pointer;
}
#wrapper,
#header,
#main {
padding: 10px 15px;
margin: 0 auto 10px auto;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
#header {
min-width: 40vw;
max-width: 50vw;
}
#main {
min-height: 65vh;
}
.nav-link {
float: left;
margin: 0 5px 0 5px;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
.nav-link:hover {
background-color: rgba(255, 255, 255, 0.4);
}
.nav-link a {
display: block;
padding: 10px 15px;
/* width: 100%; */
/* height: 100%; */
background-color: rgba(255, 255, 255, 0.3);
}
<body>
<div id="wrapper">
<div id="header">
<table align="center">
<td class="nav-link">Main</td>
<td class="nav-link">Test</td>
<td class="nav-link">FAQ</td>
</table>
</div>
<div id="main">
<h1 style="line-height: 0%">Header</h1>
<p style="line-height: 0%; font-size: 1vw">_________________________________________________________________________________________________________</p>
<br>
<br>
</div>
</div>
</body>
https://jsfiddle.net/8gcypffm/4/
Is there a way to realize the following kind of shadow with CSS only?
So far I only managed to draw the shadow around the complete box without the recess around the inactive tab:
The Code Here
HTML:
<div class="box">
<div class="tabs">
<span class="tab active">Bild</span>
<span class="tab">Text</span>
</div>
<div class="content"></div>
</div>
CSS:
.box {
width: 200px;
height: 250px;
box-shadow: 0 0 2.5px 2px rgba(0, 0, 0, 0.18);
margin: 16px;
}
.tabs {
height: 30px;
}
.tab {
display: inline-block;
width: calc(50% - 2px);
height: 30px;
text-align: center;
line-height: 30px;
}
.tab:not(.active) {
/* Should be removed in the final solution with correct shadows... */
background-color: rgba(0, 0, 0, 0.18);
}
The solution doesn't need to take care of legacy browsers (< IE 10).
Thanks
Use This CSS
.tab.active {
box-shadow: 0 -5px 2.5px 2px rgba(0, 0, 0, 0.18);
position: relative;
z-index: 99999;
}
.tab {
background: #fff none repeat scroll 0 0;
display: inline-block;
height: 30px;
line-height: 30px;
text-align: center;
width: calc(50% - 2px);
}
.content {
box-shadow: 0 0 2.5px 2px rgba(0, 0, 0, 0.18);
margin-top: 0;
min-height: 50px;
position: relative;
z-index: 999;
}
Edit Your CSS
.box {
- Remove this-
/*box-shadow: 0 0 2.5px 2px rgba(0, 0, 0, 0.18); */
height: 250px;
margin: 16px;
width: 200px;
}