Align icons and text with CSS - html

I want the text to be placed to the right of each icon but it ends up looking like this:
I've tried setting the .panel display to table but it looks like a mess.
.panel {
padding: 0 18px;
background-color: white;
/*#F7F7F7;*/
display: none; //With a function it's then displayed as Block
overflow: hidden;
border: 0.5px solid #ccc;
}
.lock {
float: right;
}
.status {
float: left;
}
.status_icon {
width: 30px;
height: 30px;
margin: 0;
margin-top: 4px;
margin-right: 15px;
cursor: pointer;
vertical-align: baseline;
display: table-cell;
}
.lock_icon {
width: 30px;
height: 30px;
margin: 0;
margin-top: 4px;
margin-right: 15px;
cursor: pointer;
vertical-align: baseline;
display: table-cell;
}
<div class="panel">
<div class="status">
<img src="Iconos/closed.png" alt="Closed" class="status_icon" onclick="stat(event,this);">
<p class="stat_text">Current status: Closed</p>
</div>
<div class="lock">
<img src="Iconos/locked.png" alt="Locked" class="lock_icon" onclick="lock(event,this);">
<p class="lock_text">Current lock: Locked</p>
</div>
</div>

Using display:flex would be best approach to achieve this result. Try this CSS code.
.panel {
padding: 0 18px;
background-color: white;
overflow: hidden;
border: 0.5px solid #ccc;
display: flex;
justify-content: space-between;
}
.lock {
display: flex;
}
.status {
display: flex;
}
.status_icon {
width: 30px;
height: 30px;
margin: 0;
margin-top: 4px;
margin-right: 15px;
cursor: pointer;
}
.lock_icon {
width: 30px;
height: 30px;
margin: 0;
margin-top: 4px;
margin-right: 15px;
cursor: pointer;
}

Related

How to put button at the bottom-right of the box

I'm just wondering how I can put my button at the right-bottom of the parent box.
I have put position: relative; to the parent box and used position: absolute; for the button class.
This worked perfectly. However, the button overlapped with the contents of the parent box.
What would be the best way to fix this?
Here's my html and css Thank you!!
.color {
border: 1px solid black;
width: 70%;
margin: 10px auto;
padding: 0 30px;
position: relative;
}
.color p {
display: inline-block;
width: 200px;
height: 80px;
margin-right: 10px;
text-align: center;
line-height: 78px;
}
p.black {
background: black;
color: white;
}
p.gray {
background: gray;
color: white;
}
p.blue {
background: blue;
color: white;
}
p.white {
border: 1px solid black;
}
.btn {
position: absolute;
right: 10px;
bottom: 10px;
}
.btn a {
display: inline-block;
background: #efd9ca;
padding: 25px;
width: 300px;
text-align: center;
text-decoration: none;
}
<h1 class="heading">color</h1>
<p class="black">black</p>
<p class="gray">gray</p>
<p class="white">white</p>
<p class="blue">blue</p>
<div class="btn">Mozilla color collection website</div>
I removed your relative and absolute position declarations. Then I added following css declrations:
.btn {
float: right;
margin-bottom: -20px;
}
float: right; will align the button to the right side. With margin-bottom: -20px; you counter the padding bottom of 30px so that the spacing will only be 10px as previos attempted.
.color {
border: 1px solid black;
width: 70%;
margin: 10px auto;
padding: 0 30px;
}
.color p {
display: inline-block;
width: 200px;
height: 80px;
margin-right: 10px;
text-align: center;
line-height: 78px;
}
p.black {
background: black;
color: white;
}
p.gray {
background: gray;
color: white;
}
p.blue {
background: blue;
color: white;
}
p.white {
border: 1px solid black;
}
.btn a {
display: inline-block;
background: #efd9ca;
padding: 25px;
width: 300px;
text-align: center;
text-decoration: none;
}
.btn {
float: right;
margin-bottom: -20px;
}
<h1 class="heading">color</h1>
<p class="black">black</p>
<p class="gray">gray</p>
<p class="white">white</p>
<p class="blue">blue</p>
<div class="btn">Mozilla color collection website</div>

A Section in My HTML is having a problem with its position

I have a site and it has 2 sections. the left section is a navigation bar with menus below.
The section next to it is the main section or where the website content must be placed. My problem is the right section is positioned a few pixels from the header. How can i fix this? I provided some image to let you see how the website should look like.
/*WRITTEN USING SASS*/
#side-menu{
margin-top: 25px;
.side-menu-bg {
width: max-content;
h3 {
position: absolute;
color: white;
padding: 0px 18px;
font-size: 27px;
}
img {
display: -webkit-box;
}
}
.side-nav-bar {
width: 210px;
position: unset;
margin-top: -3px;
display: inline-flex;
z-index: 1;
flex-direction: column;
overflow-x: hidden;
background-color: #ffffff;
a {
display: inherit;
color: #707070;
text-decoration: none;
font-size: 15px;
padding: 10px 18px;
position: relative;
border-bottom: 1px solid #e8e8e8;
}
.active-link{
color: #a40022;
border-bottom: 2px solid #8a001c;
}
}
.right-contents {
float: right;
.title h3 {
font-size: 38px;
}
.body-content {
background-color: #d3d3d3;
height: 1094px;
width: 738px;
}
}
}
<div class="wrapper"> <!--to make contents center-->
<div id="side-menu">
<div class="side-menu-bg">
<h3>KU 스타트업</h3>
<img src="images/bg/bg_03.png">
</div>
<div class="side-nav-bar">
인사말
창업 비전
창업 프로세스
창업부서소개
찾아오시는 길
</div>
<div class="right-contents">
<div class="title">
<h3>인사말</h3>
<div class="body-content">
sample text
</div>
</div>
</div>
</div>
</div>
Add margin: 0 to your h3 tag.. h3 has margin-to and margin-bottom by default. thanks
.right-contents {
float: right;
.title h3 {
font-size: 38px;
margin: 0; /*add this*/
}
.body-content {
background-color: #d3d3d3;
height: 1094px;
width: 738px;
}
<style>
/*WRITTEN USING SASS*/
#side-menu{
margin-top: 25px;
.side-menu-bg {
width: max-content;
h3 {
position: absolute;
color: white;
padding: 0px 18px;
font-size: 27px;
}
img {
display: -webkit-box;
}
}
.side-nav-bar {
width: 210px;
position: unset;
margin-top: -3px;
display: inline-flex;
z-index: 1;
flex-direction: column;
overflow-x: hidden;
background-color: #ffffff;
}
a {
display: inherit;
color: #707070;
text-decoration: none;
font-size: 15px;
padding: 10px 18px;
position: relative;
border-bottom: 1px solid #e8e8e8;
}
.active-link{
color: #a40022;
border-bottom: 2px solid #8a001c;
}
}
.right-contents {
width: 65%;
margin-top: -3px;
display: inline-flex;
.title h3 {
font-size: 38px;
}
.body-content {
background-color: #d3d3d3;
height: 1094px;
width: 738px;
}
</style>

Flexbox <p> element overlapping image on page resize

When I resize my page, the text from my right column overlaps the image in the left column, like so:
How do I stop this and make the right column stay where it is, or go below the image when the page is resized? I don't want to change the layout of the page when it's fullscreen, but I want it to be responsive.
#import url(https://fonts.googleapis.com/css?family=Raleway);
body {
margin: 0;
font-family: 'Raleway', georgia, arial;
background-color: #e0e0e0;
text-align: center;
}
h1 {
color: #aaaaaa;
text-align: left;
}
.sortFilms {
text-align: left;
display: inline-block;
background-color: #ff6699;
width: 80%;
padding: 20px;
}
header {
text-align: center;
display: inline-block;
border-bottom: 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-style: solid;
border-color: #aaaaaa;
width: 80%;
padding: 20px;
background-color: #e0e0e0;
}
.newFilm {
text-align: left;
display: inline-block;
background-color: #ff6699;
width: 80%;
padding: 20px;
}
label {
font-size: 1em;
padding: 6px;
color: #fff;
font-weight: 700;
display: block;
text-align: left;
}
.form {
margin: auto;
display: flex;
text-align: center;
flex-direction: column;
}
h2 {
font-weight: 700;
font-size: 2em;
width: 50%;
color: #B2365F;
}
#formTitle {
margin-top: 0;
margin-bottom: 0;
}
.row {
margin-left: -20px;
display: grid;
grid-template-columns: 1fr 1fr;
}
.col {
padding: 20px;
}
input,
textarea,
select {
width: 100%;
display: block;
border-radius: 25px;
background-color: #e0e0e0;
padding: 10px;
border: none;
box-sizing: border-box;
}
}
.tagline {
margin: 0;
color: #333333;
font-size: 1em;
font-weight: 700;
}
input::placeholder {
color: #000;
}
textarea::placeholder {
color: #000;
}
#modifyFilmButton {
float: right;
}
#media only screen and (max-width: 700px) {
.row {
grid-template-columns: 1fr;
}
}
#media screen and (max-width:800px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border: 2px solid #e0e0e0;
background-color: #e0e0e0;
display: block;
margin-bottom: .625em;
border-radius: 20px;
}
table td {
display: block;
font-weight: bold;
font-size: 1.2em;
text-align: left;
padding: 15px;
}
table td::before {
/*
* aria-label has no advantage, it won't be read inside a table
content: attr(aria-label);
*/
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
.oldFilm {
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
text-align: left;
display: inline-block;
background-color: #AAAAAA;
width: 80%;
padding: 20px;
}
#oldTitle {
margin-top: 0;
margin-bottom: 0;
color: #ff6699;
padding-bottom: 20px;
}
td {
padding: 5px;
font-weight: bold;
}
table {
border-collapse: collapse;
text-align: center;
width: 100%;
}
thead {
background: #ff6699;
}
.reviewImage {
width: 200px;
border-radius: 20px;
}
.filmRow img {
width: 300px;
height: 420px;
margin: 10px;
border-radius: 20px;
}
.filmRow {
-webkit-flex-flow: row wrap;
justify-content: space-around;
}
#filmContainer {
width: 100%;
margin-top: 10px;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-around;
}
#date {
padding: 5px;
text-align: left;
width: 30%;
}
#date input {
width: auto;
}
#date label {
display: -webkit-inline-box;
}
#oldTitle2 {
margin-top: 0;
margin-bottom: 0;
color: #ff6699;
}
.genre {
padding: 5px;
text-align: left;
width: 60%;
}
.genre input {
width: auto;
}
.genre label {
display: -webkit-inline-box;
}
/* third page */
#filmImage {
width: 300px;
height: 420px;
margin: 10px;
border-radius: 20px;
}
#filmTitle {
font-weight: 700;
margin-bottom: 20px;
font-size: 3em;
width: 100%;
color: #B2365F;
}
#leftcol {
width: 25%;
display: flex;
flex-direction: column;
}
#rightcol {
display: flex;
flex-direction: column;
width: 50%;
margin: 5px;
}
#rightcol label {
padding: 0;
}
#rightcol p {
margin-bottom: 10px;
margin-top: 2px;
}
#filmContainer2 {
width: 100%;
margin-top: 10px;
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: center;
}
#indent {
margin: 5px;
}
<header>
<img src="img/rv-logo.png">
<p class="tagline">Want to know whether or not it's worth paying to watch a certain film or not? See what we think first!</p>
</header>
<div class="sortFilms">
<div id="filmContainer2">
<div id="leftcol">
<img id='filmImage' src="https://images-na.ssl-images-amazon.com/images/I/51Gh9OaWVcL.jpg">
</div>
<div id="rightcol">
<p id='filmTitle'>Deadpool</p>
<div id="indent">
<label>Year:</label>
<p id='filmYear'>2016</p>
<label>Genre:</label>
<p id='filmGenre'>Action/Comedy</p>
<label>Rating:</label>
<p id='filmRating'>9/10</p>
<label>Synopsis:</label>
<p id='filmSynopsis'>blah blah blah blah</p>
</div>
<a href='viewFilms.html'>Back to list</a>
</div>
</div>
</div>
The problem is with your image the div containing the image has 25% width, but your image has a width which is larger than 25% of its parent so the image overflows its parent. You should not do like that try to set the image width to 100%.
To fix your problem set the width of the image to 100% and adjust the width of its parent to adjust image size
And one more tip if you're using flexbox use the property flex-wrap:wrap...so the divs inside the flex will automatically shift down according to screen size
To learn more about flex check this link out
https://css-tricks.com/snippets/css/a-guide-to-flexbox/

layout changed once published live

I received help centering an image within a box using a "helper" pseudo element element, which was working until I published it live. I'm not sure what's going on.
you can see whats going on at live link. And this is the code I was using for the layout
Code:
.offer {
width: 288px;
float: left;
margin-right: 25px;
}
.box {
position: relative;
display: block;
border: solid 3px #19468d;
height: 310px;
width: 100%;
margin-top: 11px;
text-align: center;
}
.price span {
font-family: avenir next;
font-weight: 700;
background-color: #19468d;
color: white;
font-size: 21px;
padding: 0px 5px;
left: 0;
padding-left: 0;
}
.price a {
position: relative;
font-family: avenir next;
font-weight: 700;
background-color: #19468d;
color: white;
font-size: 21px;
padding: 1px 7px;
left: 3px;
bottom: 1px;
border-style: solid;
border-color: #19468d;
}
.price a:hover {
color: #19468d;
background-color: white;
border-style: solid;
}
#cost {
position: absolute;
left: 0px
}
#info {
position: absolute;
bottom: 0px;
right: 0px
}
.box img {
display: inline-block;
margin: 0 auto;
text-align: center;
max-width: 252px;
vertical-align: center;
}
#grid {
margin: 0px;
display: flex;
display: -webkit-flex;
/* Safari 8 */
flex-wrap: wrap;
-webkit-flex-wrap: wrap;
/* Safari 8 */
-webkit-justify-content: center;
/* Safari 8 */
margin-left: 20px;
}
.helper {
display: inline-block;
height: 100%;
vertical-align: middle;
}
.price {
text-align: left
}
.price #dollar {
padding-right: 0px;
padding-left: 5px;
}
<div class="offer">
<div class="box">
<div class="price">
<span id="dollar">$</span><span>27</span>
</div>
<span class="helper"></span>
<img src="http://cdn2.hubspot.net/hubfs/75704/JPs-Slices/2016_Yes/img/floorexammat.jpg">
<div class="price" id="info">
Buy Now
</div>
</div>
Rather use flex for the images. On the ".box" you can do
display:flex;
justify-content: center;
and remove the helper.

Align span inside of div

I’m looking for a way to make sure that all label have the same space to the bottom border. (It should look like the image, and not like the fiddle)
JsFiddle
Goal:
My CSS:
.outerDiv {
text-align: center;
/*display: inline-block;*/
float: left;
border-radius: 10px;
border: 2px solid #c3c3c3;
height: 100px;
width: 100px;
margin: 5px;
}
.innerDiv {
width: 80%;
height: 100%;
line-height: 50px;
margin: 0 auto;
}
.errorLabel {
background-color: #a90329;
padding: .2em .6em .3em;
font-size: 100%;
color: #fff;
border-radius: .25em;
line-height: 1;
vertical-align: baseline;
font-weight: 700;
text-align: center;
white-space: nowrap;
box-sizing: border-box;
overflow: hidden;
display: block;
}
Your vertical-align doesn't have any affect due to your display: block.
Try changing vertical-align to "bottom" and display to "inline-block". Then adjust your bottom margin/padding to your desire!
.errorLabel {
background-color: #a90329;
padding: .2em .6em .3em;
font-size: 100%;
color: #fff;
border-radius: .25em;
line-height: 1;
vertical-align: bottom;
font-weight: 700;
text-align: center;
white-space: nowrap;
box-sizing: border-box;
overflow: hidden;
display: inline-block;
margin-bottom: 0.5em;
width: 100%;
}
Edit:
Added width: 100%; to keep the labels the full width.
As #RokoC.Buljan pointed out in the example in the comments, this can be accomplished with cleaner CSS. My example above is just a few small modifications on the OP's original code (in case those classes are used elsewhere too). :)
Absloute positioning would seem the logical choice.
.errorLabel {
background-color: #a90329;
padding: .2em .6em .2em;
font-size: 100%;
color: #fff;
border-radius: .25em;
line-height: 1;
vertical-align: baseline;
font-weight: 700;
text-align: center;
white-space: nowrap;
box-sizing: border-box;
overflow: hidden;
display: block;
position: absolute;
bottom:0;
left:50%;
transform:translateX(-50%);
margin-bottom: 5px;
}
.outerDiv {
text-align: center;
/*display: inline-block;*/
float: left;
border-radius: 10px;
border: 2px solid #c3c3c3;
height: 100px;
width: 100px;
margin: 5px;
}
.innerDiv {
width: 80%;
height: 100%;
line-height: 50px;
margin: 0 auto;
position: relative
}
.errorLabel {
background-color: #a90329;
padding: .2em .6em .2em;
font-size: 100%;
color: #fff;
border-radius: .25em;
line-height: 1;
vertical-align: baseline;
font-weight: 700;
text-align: center;
white-space: nowrap;
box-sizing: border-box;
overflow: hidden;
display: block;
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
margin-bottom: 5px;
}
<div class="outerDiv">
<div class="innerDiv"> <span>123123</span>
<span class="errorLabel">OK</span>
</div>
</div>
<div class="outerDiv">
<div class="innerDiv"> <span>123123</span>
<span class="errorLabel">Error2</span>
</div>
</div>
<div class="outerDiv">
<div class="innerDiv"> <span>123123</span>
<span class="errorLabel">
Line1<br/>
Line2
</span>
</div>
</div>
<div class="outerDiv">
<div class="innerDiv"> <span>123123</span>
<span class="errorLabel">
Line1<br />
Line2
</span>
</div>
</div>
You can fiddle with the bottom amount:
http://jsfiddle.net/z7hL3any/5/
add:
.errorLabel {
position: relative;
}
.innerDiv {
position: absolute;
bottom: 5px;
width: 100%; }
try this
.errorLabel {
background-color: #a90329;
border-radius: 0.25em;
bottom: 0;
box-sizing: border-box;
color: #fff;
display: block;
font-size: 100%;
font-weight: 700;
line-height: 1;
margin-bottom: 10px;
overflow: hidden;
padding: 0.2em 0.6em 0.3em;
position: absolute;
text-align: center;
vertical-align: baseline;
width: 100%;
}
.it should also work