I was wondering if there is an alternative method to achieving the results shown in the attached picture. I used absolute positioning to get .resume-icon-container to sit flush with .resume-container.
Every time I tried to add padding or height/width to .resume-icon-container it would undesirably resize .resume-container. I experimented with overflow: auto and the z-index but the only way I could achieve the results I want is with absolute positioning and adding margin-left to position it then padding and font-size to make it flush with .resume-container. I was browsing similar questions as well and someone said to add box-sizing: border-box but I already declared that setting in my CSS reset under the * selector.
I would prefer to stay away from absolute positioning for responsive purposes, so I was wondering if there is another way to achieve what I want.
This is the desired result:
.resume-container {
display: flex;
flex-direction: row;
background: rgba(144, 144, 144, 0.3);
margin-top: 20px;
border-radius: 20px;
padding: 20px;
width: 350px;
margin-left: auto;
margin-right: auto;
align-items: center;
justify-content: space-between;
}
.resume-container h1 {
color: #fff;
font-size: 25px;
}
.resume-icon-container {
background: rgba(196, 196, 196, 0.3);
padding: 20px;
position: absolute;
margin-left: 268px;
border-radius: 20px;
font-size: 10px;
}
.resume-icon-container i {
color: #fff;
}
<div class="resume-container">
<h1>Download Resume</h1>
<div class="resume-icon-container">
<i class="fa-solid fa-file fa-3x"></i>
</div>
</div>
Remove the absolute positioning and padding and use margin-left on your h1.
.resume-container {
display: flex;
flex-direction: row;
background: rgba(144, 144, 144, 0.3);
margin-top: 20px;
border-radius: 20px;
width: 350px;
margin-left: auto;
margin-right: auto;
align-items: center;
justify-content: space-between;
}
.resume-container h1 {
color: #fff;
font-size: 25px;
margin-left: 1em;
}
.resume-icon-container {
background: rgba(196, 196, 196, 0.3);
padding: 20px;
border-radius: 20px;
}
.resume-icon-container i {
color: #fff;
width: 100%;
}
<script src="https://kit.fontawesome.com/6140596fcb.js" crossorigin="anonymous"></script>
<div class="resume-container">
<h1>Download Resume</h1>
<div class="resume-icon-container">
<i class="fa-solid fa-file fa-3x"></i>
</div>
</div>
The way you are tuning those margins and paddings, you will always be looking at something different depending on the size of the screen. You need to use relative positioning so that the items appear on the screen the same regardless of the number of pixels. It can also get confusing to mix margin with padding. Margin will push the element from its nearest element while padding will push elements inside that element away from the left,top,etc.
I like to start by creating a container for each element so that we can design each new div element like its own page.
Consider the following code:
<div id="View">
<div id="OptionBlock">
<div id="Options1">
<div id="AddDocument" class="options">Add New Document<div id="DocumentIcon"></div></div>
<div id="AddTemplate" class="options">Add New Template<div id="TemplateIcon"></div></div>
</div>
<div id="Options2">
<div id="ChangeSignature" class="options">Change Your Signature<div id="SignatureIcon"></div></div>
<div id="Settings" class="options">Settings and Subscription<div id="SettingsIcon"></div></div>
</div>
</div>
</div>
#View {
width: 100%;
height: 60%;
}
#OptionBlock {
width: 100%;
}
#Options1 {
width: 100%;
float: left;
}
#Options2 {
width: 100%;
float: left;
}
#AddDocument {
float: left;
padding: 5px;
width: 25%;
height: 38%;
margin-left: 24%;
margin-right: 2%;
margin-top: 2%;
text-align: center;
border: 2px solid black;
border-radius: 25px;
background-color: #ffffff;
font-size: x-large;
font-weight: bold;
}
#AddTemplate {
float: left;
padding: 5px;
width: 25%;
height: 38%;
margin-top: 2%;
margin-right: 24%;
text-align: center;
border: 2px solid black;
border-radius: 25px;
background-color: #ffffff;
font-size: x-large;
font-weight: bold;
}
Notice how I treat the outer boxes as large containers, defining all the total width and height we need, then leaving it to the css for particular elements showing content to position themselves within that container on the screen. The width and left and right margins of elements #AddDocument and #AddTemplate add up to 100% width so that the entire box it is placed in is accounted for.
Preview CSS Placements (this renders dead center at the top of the webpage)
It's just a matter of playing with the css.
For this kind of "trial and error" problem you should use CodePen or similar. It'll make your life much easier.
.resume-container {
display: flex;
flex-direction: row;
background: rgba(144, 144, 144, 0.3);
margin-top: 20px;
border-radius: 20px;
/* padding: 20px;*/
width: 350px;
margin-left: auto;
margin-right: auto;
align-items: center;
justify-content: space-between;
}
.resume-container h1 {
color: #fff;
font-size: 25px;
padding: 20px;
margin: 0;
}
.resume-icon-container {
background: rgba(196, 196, 196, 0.3);
padding: 20px;
float: right;
/*margin-left: 268px;*/
border-radius: 20px;
/*font-size: 10px;*/
height: 100%;
}
.resume-icon-container i {
color: #fff;
}
.bi {
font-size: 2rem;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.8.1/font/bootstrap-icons.css" rel="stylesheet" />
<div class="resume-container">
<h1>Download Resume</h1>
<div class="resume-icon-container">
<i class="fa-solid fa-file fa-3x"></i>
<i class="bi bi-file-earmark-text"></i>
</div>
</div>
Related
I have a problem with text wrapping within my container. Working code snippet below.
In the sample above, everything works fine until the stepper-hor container has enough space to present the content:
I'd like the step-text container (box with blue border) to always stay to in line with step-additional-label container (box with green border). Step-text container (box with blue border) should also wrap the text inside when container's width shrinks.
Currently, when I set stepper-hor width to 350px, step-text container (box with blue border) goes below the box with green border:
What I wish to achieve is something like this:
I've tried using different variations of
display: inline-block;
overflow-wrap: break-word;
in lines 64-65 but that didn't work as expected and often messed up the horizontal alignment between the step-circle-active and step-text.
Any help is very much appreciated.
Here is a more editing-friendly sandbox to play around:
https://codesandbox.io/s/confident-breeze-qm4bf?file=/styles.css
EDIT: #Temani and #Daniel below suggested display: flex; which helped nicely.
Here is the codesandbox fork with implemented changes:
https://codesandbox.io/s/suspicious-wescoff-wgyny?file=/styles.css
Thank you lads.
body {
font-family: "Arial Light";
background-color: #1e1e1e;
padding-top: 60px;
}
.stepper-hor {
background-color: #252525;
display: flex;
flex-direction: column;
/* width: 350px; */
/* HERE YOU CAN CHANGE THE WIDTH OF THE CONTAINER */
}
.step-container {
border: 1px solid rgba(255, 255, 0, 0.459);
min-height: 63px;
margin: 0;
}
.step-circle-default {
display: inline-block;
height: 21px;
width: 21px;
background-color: #666666;
color: #333333;
font-size: 0.65rem;
font-weight: bold;
border-radius: 50%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
text-align: center;
line-height: 21px;
margin-right: 9px;
}
.step-circle-active {
display: inline-block;
height: 21px;
width: 21px;
background-color: #d85603;
color: #ffffff;
font-size: 0.65rem;
font-weight: bold;
border-radius: 50%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
text-align: center;
line-height: 21px;
margin-right: 9px;
}
.step-additional-label {
border: 1px solid rgba(0, 128, 0, 0.575);
display: inline-block;
min-width: 26px;
font-size: 0.59rem;
color: #666666;
padding-right: 21px;
}
.step-text {
border: 1px solid rgba(0, 0, 255, 0.404);
display: inline-block;
overflow-wrap: break-word;
font-size: 0.82rem;
color: #ffffff;
position: relative;
min-height: 54px;
top: 4px;
}
.step-line {
border: 1px solid #444444;
}
<div class="stepper-hor">
<p class="step-container" }>
<span class="step-circle-default">1</span>
<span class="step-additional-label">100%</span>
<span class="step-text">Take a shower</span>
</p>
<p class="step-container" }>
<span class="step-circle-default">2</span>
<span class="step-additional-label">10%</span>
<span class="step-text">Read a book</span>
</p>
<p class="step-container" }>
<span class="step-circle-active">13</span>
<span class="step-additional-label">79%</span>
<span class="step-text">
Do some activity with long description that will require more space
</span>
</p>
</div>
You should change your step-container structure and use display: flex in order to achieve the result you want.
Here is an example:
HTML
<div class="step-container">
<div class="stats">
<span class="step-circle-active">13</span>
<span class="step-additional-label">79%</span>
</div>
<p class="step-text">
Do some activity with long description that will require more space
</p>
</div>
CSS
.step-container {
display: flex;
}
.step-container .stats {
display: flex;
}
There is no point in creating the step-container as a p element with multiple spans in it.
Adding CSS property display: flex; to the container .step-container will do the thing.
I am working on my first website and its very basic code, but
the div "beyza", on the website (on the image) its the text "Site designed by Beyza" in my footer, keeps showing extra space under, how can I resolve the issue? here is how it looks
Many thanks in advance!
footer {
width: 100%;
position: relative;
background-color: rgb(0, 255, 0);
overflow: hidden;
}
.container {
width: %100;
position: relative;
background-color: rgb(0, 255, 0);
}
.instagram {
padding-top: 30px;
display: inline-block;
}
footer small {
display: block;
margin: 20px;
font-size: 21px;
color: #FFF;
text-align: center;
background-color: rgb(0, 255, 0);
}
.sponsor {
float: left;
padding-left: 15px;
margin-bottom: 15px;
display: block;
}
.beyza {
font-size: 14px;
color: #FFF;
float: right;
margin-right: 15px;
}
<footer>
<div class="container">
<div class="instagram">
<a href="https://www.instagram.com/alix.bizet/">
<img src="images/instagram.png" alt="instagram">
</a>
</div>
<small>© 2016 Hair by Hood Project </small>
<div class="sponsor">
<a href="http://designmuseum.org">
<img src="images/DesMus2.png" alt="designmuseum">
</a>
</div>
<div class="beyza">Site designed by Beyza #GRAPHIC DIALOGUE
</div>
</div>
</footer>
Remove margin-bottom from .sponsor class
.sponsor {
float: left;
padding-left: 15px;
->margin-bottom: 15px;
display: block;
}
If you want to keep sponsor higher just add width: 100% to sponsor.
You can also wrap sponsor and beyza in another div element and make it:
display: flex;
flex-direction: row;
justify-content: space-between,
align-items: flex-start;
remove margin-bottom from sponsor
add align-self: flex-end to beyza
You have some issues here:
you missed your closing anchor
<a href="https://graphicdialogue.co">GRAPHIC DIALOGUE</div>
typo
.container{width: %100}
adjustmargin-bottom
.sponsor {
float: left;
padding-left: 15px;
margin-bottom: 15px; //this is the problem-try reduce the size
display: block;
}
I am using bootstrap and there are different rows containing 2 columns each.
The problem is that they are not aligning properly.
This is what I want
and this is what I am getting
Please tell me what's wrong here.
I have been trying this for more than an hour and somehow it's not working.
Here's the css for this
.container {
text-align: center;
width: 80%;
}
.first {
background: rgb(0, 30, 58);
color: white;
}
.span1,
.span2 {
font-size: 36px;
font-weight: bold;
}
.span1 {
color: rgb(72, 174, 137);
}
[type="text"] {
border-radius: 25px;
padding-left: 5px;
}
[type="submit"] {
color: white;
background-color: rgb(72, 174, 137);
border-radius: 25px;
position: relative;
margin-left: -25px;
}
.use {
height: 85%;
margin: 0 auto;
}
.box {
border: 3px solid rgb(72, 174, 137);
width: 55%;
margin: 0 auto;
max-height: 210px;
}
.para {
text-align: left;
margin-right: 0;
padding-right: 0;
padding-top: 15px;
}
.para strong {
font-weight: 900;
font-size: 16px;
}
.second {
margin-bottom: 30px;
border: 1px solid green;
width: 10%;
}
.threebox {
width: 90%;
margin: 0 auto;
padding-left: 70px;
}
.col-lg-4 {
height: 40%;
}
.col-lg-4 > p {
background-color: white;
border: 2px solid white;
border-top-color: green;
width: 200px;
height: 160px;
box-shadow: 10px 10px 15px;
}
.positions {
margin-top: 60px;
position: relative;
margin-bottom: -50px;
z-index: 2;
}
.positions > h1 {
font-size: 30px;
font-weight: bold;
}
.spanf {
font-size: 18px;
font-weight: bold;
}
.features {
text-align: center;
padding-bottom: 40px;
width: 100%;
margin: 0 auto;
background-color: rgb(242, 243, 245);
height: 1500px;
z-index: 1;
padding-top: 120px;
margin-bottom: 0;
}
.features .row {
width: 65%;
margin: 0 auto;
}
.features .row p {
text-align: left;
padding-left: 20px;
}
.features button {
border-radius: 20px;
}
.features .row {
margin-top: 40px;
}
.features img {
/* width: 98%; */
/* height: 98%; */
left: 12px;
top: -12px;
box-shadow: -2px 2px 9px;
}
.features .row .col-lg-6 {
/* padding-right: 15px; */
/* padding-left: 2px; */
}
.imgright {
position: relative;
border: 3px solid rgb(72, 174, 137);
top: 5%;
width: 40%;
padding-bottom: 0px;
padding-right: 2px;
padding-left: 0;
margin-left: 20px;
margin-top: 20px;
}
.img2 {
position: relative;
/* padding-bottom: 10px; */
}
.imgleft {
position: relative;
border: 3px solid rgb(72, 174, 137);
width: 40%;
top: 5%;
margin-left: 10px;
margin-top: 20px;
padding: 0;
}
.img3 {
position: relative;
left:30px;
/* top:-20px; */
/* padding-bottom: 10px; */
}
.pillars {
background-color: rgb(72, 174, 137);
height: 350px;
top: 0;
}
Here's the link to the codepen for this - codepen
I have updated the image to show the error properly.
each row has the image and row on different sides
and thus the rows are not aligning properly as shown in the image.
Try to not change col- divs styles. create other blocks inside them to get what you want. and remember that col- class has paddings.
i would try something like
<div class="row">
<div class="col-lg-6">
<div class="text-left">
<div class="bordered-box">
<img class="img-responsive img3" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
</div>
</div>
<div class="col-lg-6">
<p>EASY TO UNDERSTAND<br><span class="spanf">Optimize Your Product & Category<br> Performance</span><br>
There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.<br>
<button>Join Now</button></p></div>
</div>
with style to bordered-box
.bordered-box{
display:inline-block;
border:3px solid #46ab86;;
}
and here's the jsfiddle
You need to make sure you're using the columns correctly, or else you're styling will just override everything. The idea is that you don't need to use much CSS at all, as it's all in the framework.
Important things are that each row, must have it's own container using row as the class. This is what gives it proper structure, and block-ness(!).
Cut down on all your extra styling, as it's not needed. The Bootstrap column classes do this well enough just by themselves.
Below is a pure example of just using Bootstrap to get the rows aligned, and the text set to left or right of the main page.
Example:
<div class="row">
<div class="col-md-6"><p>Your first row text item, left aligned by default.</p></div>
<div class="col-md-6"><img src="your-image-file.jpg" class="img-responsive" alt="dont-forget-your-alt" /></div>
</div>
<div class="row">
<div class="col-md-6"><img src="your-second-image-file.jpg" class="img-responsive" alt="really-dont-forget-your-alt" /></div>
<div class="col-md-6 text-right"><p>Your second row text item, wich needs to be right aligned by adding the class to the p tag.</p></div>
</div>
etc...
do that in css :
.right{ float:right; margin-right:10px;}
and html :
<div class="row">
<div class="col-lg-6 imgleft"> <img class="img-responsive img3" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph"> </div>
<div class="col-lg-6 right">
<p>ECOMMERCE FOCUS
<br><span class="spanf">Decision Focused Dashboards To<br> Supercharge Your Ecommerce Business</span>
<br> There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.
<br>
<button>Join Now</button>
</p>
</div>
</div>
https://jsfiddle.net/DTcHh/24772/
I have a container that usually has a width of 400px. When the screen gets smaller, its width is reduced to 300px. These two values are static and don't change.
I have 3 buttons within this container. At the wider width, I'd like to have 2 side by side and the 3rd one on the line below. All of them are centered.
When the container is compressed, I'd like to have all the buttons stack on top of each other centered.
I can get it at the wide width but can't get it at the narrow width.
HTML:
<div id="varied-width">
<div class="pg-sp2 prompt-gate">Did you find what you were looking for?
<div class="pg-3-buttons">
<button class="prompt-gate-button" onclick="PromptGate_sp2(1)">Yes</button>
<button class="prompt-gate-button" onclick="PromptGate_sp2(0)">No, you suck</button>
</div>
<button class="prompt-gate-button" onclick="PromptGate_sp2(2)">No, I need help.</button>
</div>
</div>
CSS:
body {
width: 400px;
}
.prompt-gate {
margin-top: 25px;
margin-bottom: 15px;
background-color: #fefab1;
border: 1px solid #ffd532;
padding: 10px;
text-align: center;
}
.prompt-gate-button {
background-color: #0E80B4;
color: white;
font-size: 12px;
height: 30px;
width: 72px;
border: none;
margin: 15px 25px;
outline: none;
font-style: normal;
cursor: pointer;
}
.pg-3-buttons {
display: inline-block;
margin-top: 10px;
}
.pg-3-buttons .prompt-gate-button {
float: left;
}
.pg-sp2 button {
margin: 5px 15px;
width: 120px;
padding: 10px 0px;
}
.pg-sp2 > button {
}
.small-width {
width: 300px;
}
Fiddle: http://jsfiddle.net/je821vz9/10/
Used flex layout instead: http://jsfiddle.net/je821vz9/7/
Added this to .prompt-gate style and then cleaned up some of the conflicting HTML and CSS.
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
You could use a media query and have the viewport size decided on how to display the elements.
I added the following css to your body:
body {
max-width:400px;
min-width:300px;
}
We can then add a media query to adjust how the items are laid out:
#media (max-width: 300px) {
div.pg-3-buttons .prompt-gate-button {
display:block;
float:none;
}
}
See an updated version of your example and scale down the width of your browser to see the items pop in to place at 300px.
Somehow figured it out... removed floats and moved around the button HTML so that they were all in the same container.
http://jsfiddle.net/je821vz9/19/
<div id="varied-width">
<div class="pg-sp2 prompt-gate">Did you find what you were looking for?
<div class="pg-3-buttons">
<button class="prompt-gate-button" onclick="PromptGate_sp2(1)">Yes</button>
<button class="prompt-gate-button" onclick="PromptGate_sp2(0)">No, you suck</button>
<button class="prompt-gate-button" onclick="PromptGate_sp2(2)">No, I need help.</button>
</div>
</div>
</div>
<style>
body {
width: 400px;
}
.prompt-gate {
margin-top: 25px;
margin-bottom: 15px;
background-color: #fefab1;
border: 1px solid #ffd532;
padding: 10px;
text-align: center;
}
.prompt-gate-button {
background-color: #0E80B4;
color: white;
font-size: 12px;
height: 30px;
width: 72px;
border: none;
margin: 15px 25px;
outline: none;
font-style: normal;
cursor: pointer;
}
.pg-3-buttons {
margin-top: 10px;
}
.pg-sp2 button {
margin: 5px 15px;
width: 120px;
padding: 10px 0px;
}
</style>
As part of my HTML5/CSS3 app, I need to implement zoomable image popup. When the user clicks on a small image, a full-screen popup appears containing that image in the middle with a title above it and a button to close the popup below it. Clicking on the image then removes any scaling and puts it full-size inside a box in the middle to allow scrolling - with title and "close" button staying above and below.
I'm using flex (for several reasons, including vertical centering content). The overall popup works and looks fine. Clicking on the image does increase it in size, but it resizes the box so that the "done" button is pushed below the overall popup.
Here's the jsfiddle demonstrating the issue
I don't mind the fact that the box resizes - the more room to view/scroll the larger image - but I need to ensure that the button at the bottom stays put relative to the bottom edge of the popup.
My HTML looks like this (I used a random image for demonstration):
<div id="overlay" class="hidden">
<div id="alsg">
<div class="intro">Assist with ALS</div>
<div class="box scrollable">
<img src="http://upload.wikimedia.org/wikipedia/commons/8/8c/Male_monarch_butterfly.JPG" class="fit" />
</div>
<div class="popup-buttons">
<div id="button-alsg-done" class="button button-state-action button-green right">Done</div>
<div class="clear"></div>
</div>
</div> <!-- alsg -->
</div>
With the javascript being
$('img', '#alsg').on('click', function(e) {
$(this).toggleClass('fit');
});
There's a lot of CSS, unfortunately. You'll note that there's a pretty bad mix of flex and old-school positioning. This is because the app initially didn't use flex at all and I'm in a slow process of migrating/cleaning up now.
div#overlay {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
z-index: 104;
display: flex;
align-items: center;
justify-content: center;
}
div#overlay > div {
position: relative;
width: calc(100% - 40px);
margin: 10px auto;
background-color: #A9A9A9;
border-radius: 8px;
text-align: center;
padding: 10px;
display: flex;
flex-direction: column;
}
div#alsg {
max-height: calc(100% - 40px) !important;
}
div#overlay div.intro {
color: #FFF !important;
font-size: 12pt;
margin-bottom: 10px;
}
div#overlay div.box, div.template div.box {
padding: 3px 5px;
overflow: hidden;
font-weight: bold;
position: relative;
flex-grow: 1;
}
div#alsg div.box {
text-align: center;
position: relative;
overflow: auto !important;
margin: 10px 0px 0px !important;
}
div.box {
background-color: #FFF;
color: #27374A;
border-radius: 8px;
border: 3px solid #FBE96E;
position: relative;
margin: auto;
flex-shrink: 1;
}
.fit {
max-width: calc(100% - 4px) !important;
max-height: calc(100% - 4px) !important;
}
div.popup-buttons {
margin-top: 10px;
}
#overlay .button.right {
margin-left: 10px;
}
#button-alsg-done {
margin-top: 10px;
flex-basis: 25px;
}
div.button-green {
background-color: #2CC55D;
color: #FFF;
font-weight: bold;
}
div.button-state-action {
height: 25px;
padding: 0px 5px;
line-height: 25px;
text-align: center;
border-radius: 4px;
font-size: 10pt;
font-weight: normal !important;
width: 60px;
cursor: pointer;
margin-bottom: 5px;
}
div.button {
height: 22px;
padding: 0px 2px;
line-height: 22px;
text-align: center;
border-radius: 4px;
font-size: 9pt;
width: 42px;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
}
.right {
float: right;
}
.clear {
clear: both;
}