How can I add a bottom margin using flexbox? - html

I am having difficulty understanding what to do in this scenario. I am just getting acquainted with flexbox, and I see that it stretched the children to fit the height of the parent flexbox element. I'm just trying to build some simple components without relying on bootstrap, and here I have some nested divs, with the main content being wrapped in a div with display set to flexbox, so that I can have a row of items going across like a magazine layout. The problem is that I can't set the bottom margin, nor can I set a padding for the bottom. Is there a way for me to use flexbox items and still maintain control of the space between the typography and the border of the outermost div? In the code below, I am specifically referring to the div with ID='mainContentBox". I want to include a space of about 25px between that and the div border. Thanks for your patience. I am just starting to wrap my mind around flexbox. Thanks for taking the time to help me.
#charset "utf-8";
/* CSS Document */
* {
box-sizing: border-box;
}
.rndImg {
width: 120px;
height: 132px;
float: left;
margin-right: 15px;
margin-left: 10px;
margin-bottom: 5px;
shape-outside: circle();
margin-top: 24px;
border: 2px solid blue;
border-radius: 75%;
}
#featured {
position: relative;
width: 85px;
height: 35px;
margin-left: 35px;
top: 12px;
}
#titleBP_1 {
position: absolute;
top: 20px;
left: 40%;
}
#pDate {
position: relative;
left: 77%;
top: 15px;
}
#postOnStrip {
display: inline;
}
#inOne {
width: 500px;
}
#inTwo {
width: 500px;
display: inline;
}
.blogTxt {
width: 480px;
font-family: 'Alegreya', serif;
/* 'Roboto', sans-serif; */
font-size: 13px;
line-height: .8em !important;
letter-spacing: .13em;
text-align: justify !important;
margin-top: 30px;
display: inline;
}
#topBlogReveal {
display: block;
margin-left: 345px;
}
#mainContentBox {
display: flex;
flex-flow: row;
flex-wrap: no-wrap;
justify-content: space-between;
margin-right: 25px;
margin-left: 25px;
padding-bottom: 25px;
}
#marg {
padding-bottom: 25px;
margin-bottom: 25px;
}
#titleStrip {
width: 100%;
height: 50px;
background: Lavender;
overflow: hidden;
}
#postBox {
border: 2px solid blue;
width: 97%;
height: 450px;
margin-top: 10px;
margin-bottom: 10px;
margin-left: auto;
margin-right: auto;
overflow: hidden;
background: #CCC;
}
#colorEdge1 {
margin-top: 10px;
background: black;
width: 95%;
height: 475px;
padding: 5px 5px 5px 5px;
z-index: -5;
margin-right: auto;
margin-left: auto;
}
#topBanner {
width: 100%;
height: 120px;
}
.dCap {
float: left;
line-height: 90%;
width: 1.1em;
font-size: 600%;
font-family: georgia;
}
<div id="postBox">
<div id="titleStrip">Featured
<h3 id="titleBP_1">Blog Post #1</h3>
</div>
<div id="postOnStrip">
<p id="pDate"><b>Posted On: </b><em>June 23, 2021</em></p>
<hr class="divider">
</div>
<div id="mainContentBox">
<div id="inOne">
<img id="topBgImg" class="rndImg" src="Images/473a9b83088edfa35bdba1b7691056ad.jpg">
<p class="blogTxt"><span class="dCap">W</span>hat if the opiate epidemic runs deeper than purple bruises and scabrous veins running yup and down the arms of our nation's heroine addicts? What if it isn't just a socio economic problem, nor the result of international
anatagonisms vis a vis the black marget drug trade, but rather the first symptoms of a looming existential crisis for humanity at large. The cancer patient swallows pills to ease the aching malignancy bloomin down there in the organs and tissues,
the mess of physicality from which our consciousness is supposed to arise out of. But someti,es, the cancer patient blajets hersel fin morphine just to kill that deeper ache which starts when one percieves the horizon of their own impending demnise.
And who can blame them Life is hard.</p>
</div>
<div id="inTwo">
<p class="blogTxt">What if the opiate epidemic runs deeper than purple bruises and scabrous veins running yup and down the arms of our nation's heroine addicts? What if it isn't just a socio economic problem, nor the result of international anatagonisms vis a vis
the black marget drug trade, but rather the first symptoms of a looming existential crisis for humanity at large. The cancer patient swallows pills to ease the aching malignancy bloomin down there in the organs and tissues, the mess of physicality
from which our consciousness is supposed to arise out of. But someti,es, the cancer patient blajets hersel fin morphine just to kill that deeper ache which starts when one percieves the horizon of their own impending demnise. And who can blame
them Life is hard.</p>
Read More
</div>
</div>
</div>

Related

Sticking/layering an image to top-left corner of div container

Been attempting to layer and image over the top left corner of a div container; iv achieved it once but it didn't stick to position if the page was adjusted!
^^ This is what im redesigning
^^ This is what ive managed to design myself
I have come across different posts and answers suggesting that I try to use:
display: block, relative
position: block, relative
margins, float: start
In the end I am stumped an have resorted to removing most displays besides for the p tags an its composed container:
This is the CSS I have been trying to use to make this happen
.roadmap__section__container {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
min-height: 100%;
max-height: 100%;
background-color: #383636;
align-items: center;
}
.roadmap__header {
font: 3rem "Nunito";
margin: 3% 50% 3% 50%;
}
.roadmap__phase__one {
width: 100%;
height: 100%;
}
.phase__one__img {
width: 10%;
position: absolute;
margin-left:10%;
}
.phase__one__data {
display: flex;
flex-direction: column;
width: fit-content;
height: fit-content;
align-items: flex-start;
justify-content: center;
text-align: center;
padding: 25px;
margin: 0% 5% 5% 15%;
box-shadow: 1px 1px 40px #ff00e6;
outline-color: #ff00e6;
outline-offset: 0px;
outline-style: solid;
outline-width: 3px;
border-radius: 25px;
}
.phase__one__data p {
font-size: 1.75rem;
color: #fff;
font-family: "Nunito", serif;
padding: 5px 10px;
}
Here is the HTML Code used for my redesign:
<section class="roadmap__section__container">
<h1 class="roadmap__header">Roadmap</h1>
<div class="roadmap__phase__one">
<img class="phase__one__img" src="images/CasinoWRLD__dice1" alt="">
<div class="phase__one__data">
<p>- Working To Perfect The NFT Artwork.</p>
<p>- Finalise The Marketing Plan.</p>
<p>- Plan And Develop Casino WRLD.</p>
</div>
</div>
</section>
.phase__one__img {
grid-column: 3;
width: 11%;
position: absolute;
top: 157.5%;
right: 32%;
}
.phase__zero__img {
grid-column: 1;
width: 11%;
position: absolute;
margin-left: 5%;
top: 119.75%;
}
I've found this to work currently but it is not a 100% answer, if the browser height is adjust the settings regarding ''top:157.5%'' needs to be adjusted accordingly or it will not line up with the top-left corner of the div container
The difference in the two is pertaining to it switches back and forth going down the page

How can I make this CSS card responsive?

Edit: here is a CodePen with CSS / HTML
I spend the weekend creating a CSS card for a website, only to realize that it's not responsive, at all. I'm not very well versed in CSS or responsive design, so I am hoping someone with more experience can help me out. So far, I've tried playing around with the #media tag, but I have not had any success. This is the relevant CSS:
#import url('https://fonts.googleapis.com/css?family=Muli&display=swap');
* {
box-sizing: border-box;
}
body {
background: #ffffff;
font-family: 'Muli', sans-serif;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
min-height: 100vh;
margin: 0;
}
.courses-container {
}
.course {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.2);
display: flex;
max-width: 100%;
margin: 20px;
overflow: hidden;
width: 1300px;
}
.course h6 {
opacity: 0.6;
margin: 0;
letter-spacing: 1px;
text-transform: uppercase;
}
.course h2 {
letter-spacing: 1px;
margin: 10px 0;
}
.course-preview {
background-color: #2a265f;
color: #fff;
padding: 30px;
max-width: 250px;
}
.course-preview a {
color: #fff;
display: inline-block;
font-size: 12px;
opacity: 0.6;
margin-top: 30px;
text-decoration: none;
}
.course-info {
padding: 30px;
position: relative;
width: 100%;
}
.right-container {
padding: 30px;
background-color: #fff;
width: 30%;
line-height: 200%;
}
.progress-container {
position: absolute;
top: 30px;
right: 30px;
text-align: right;
width: 150px;
}
.progress {
background-color: #ddd;
border-radius: 3px;
height: 5px;
width: 100%;
}
.progress::after {
border-radius: 3px;
background-color: #2a265f;
content: '';
position: absolute;
top: 0;
left: 0;
height: 5px;
width: 10%;
}
.progress-text {
font-size: 10px;
opacity: 0.6;
letter-spacing: 1px;
}
This is a simple suggestion, using CSS Grid. It's a two column card (as yours): the left column width-fixed (300px), the right column width-fluid. I've applied a little gap between them just to make my example clearer.
.card {
max-width: 1000px;
display: grid;
grid-template: "left right" / 300px 1fr;
background-color: #fed330;
border-radius: 10px;
height: 300px;
}
.card>* {
padding: 20px;
}
.left {
grid-area: left;
}
.right {
grid-area: right;
}
#media screen and (max-width: 700px) {
.card {
grid-template: "left" "right" / 100%;
}
}
<div class="card">
<div class="left">
Lorem ipsum....
</div>
<div class="right">
Lorem ipsum...
</div>
</div>
It could be a useful starting point.
#gaston
A good way to test and learn about CSS is to use the browser's "Inspect" feature, with which you can test the css behavior in real time.
Activating, Deactivating features, changing values, and adding new ones.
You see the result in real time.
Then just adjust your code according to your tests.
Just right-click on the area you want to inspect. and then Inspect.
You will see an area with HTML and another with CSS.
Click on the areas in HTML and see the corresponding css.
***** Then just test to find the desired result.
That's how I found the solution in your code:
In the ".course" class of your css you added the "width" property twice.
"max-width: 100%;"
"width: 1000px;"
However, the last property entered has priority over the previous ones.
"width: 1000px;" is defining that your card will ALWAYS have 1000px.
SOLUTION:
Just remove: "max-width: 100%;"
And Modify "width: 1000px;" for "max-width: 1000px;"
So your card will have a maximum of 1000px, the minimum will be defined according to the width of the window
It will look like this:
.course {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 10px 10px rgba (0, 0, 0, 0.2);
display: flex;
margin: 20px;
overflow: hidden;
max-width: 1000px;
}
The #media function will set the css when the screen is adjusted to a minimum or maximum width chosen by you.
What is defined within #media will have priority over other css. but only when the window meets the width you set.
You can use this to change the shape of your card completely to very small screens, placing the purple part on top of the card for example.
If you've solved your problem, mark the right answer to help others.
Good luck.

Items with in a div move after JS event

I'm having some CSS styling issues.
Firstly, excuse the poor styling - I've just sorted out the logic of the game and am now working on the styling
The game is a simple game of rock paper scissors. And everytime I click on a square (which represents either rock paper scissors), the game logic is run and either you or the computer player get a point. Once both players get their score updated, the items with the div stripe get pushed up in the div.
I'm not sure if this a html/css issue, or an issue with JS - but what I'd like is the items with the stripe div to remain center at all times.
I've included images to show you what I mean - As I'm sure what I said is confusing you all.
Cheers
Code:
body {
margin: 0;
font-family: "Montserrat", "Avenir";
}
#header {
line-height: 1.1;
text-align: center;
margin: 0;
font-weight: normal;
text-transform: uppercase;
}
#stripe {
text-align: center;
width: 100%;
margin: 0 auto;
height: 50px;
}
#reset {
width: 5%;
}
#message {
display: inline-block;
width: 10%;
}
#yourScore {
display: inline-block;
width: 2%;
}
#compScore {
display: inline-block;
width: 2%;
}
.option {
width: 30%;
background: steelblue;
padding-bottom: 30%;
float: left;
margin: 1.66%;
border-radius: 25px;
transition: background .5s;
-webkit-transition: .5s;
-moz-transition: .5s;
}
#buttons {
margin: 20px auto;
max-width: 600px;
}
<div id="header">
<h1>Rock Paper Scissors</h1>
</div>
<div id="stripe">
<button id="reset">Reset</button>
<span id="message"><p></p></span>
<span id="yourScore" data-value="0"><p>0</p></span>
<span id="compScore" data-value="0"><p>0</p></span>
</div>
<div id="buttons">
<div id="rock" class="option">rock</div>
<div id="paper" class="option">paper</div>
<div id="scissors" class="option">scissors</div>
</div>
As mentioned in the comments, you are probably loosing the ps when updating the inner html of #message #yourScore and #compScore.
I would suggest you remove all the ps from within the stripe and change the stying to add some top/bottom paddings:
#stripe {
text-align: center;
width: 100%;
padding: 15px 0;
}

My object element wont show 100% height

I am making an accordion menu whereby I am adding a PDF inside an object element. However I just cannot get the object to show 100% of its height, therefore it makes it difficult to use.
All I would like is to know how to make the PDF file inside of the object div to show it's full height. I remember having similar issues with footers..
Thanks.
if( jQuery(".toggle .toggle-title").hasClass('active') ){
jQuery(".toggle .toggle-title.active").closest('.toggle').find('.toggle-inner').show();
}
jQuery(".toggle .toggle-title").click(function(){
if( jQuery(this).hasClass('active') ){
jQuery(this).removeClass("active").closest('.toggle').find('.toggle-inner').slideUp(200);
} else {
jQuery(this).addClass("active").closest('.toggle').find('.toggle-inner').slideDown(200);
}
});
body {
color: #4B4B4B;
font-family: ARIMO;
}
body a {
cursor: pointer;
color: #4B4B4B;
text-decoration: none;
}
body section {
margin-bottom: 90px;
}
body section h1 {
text-transform: uppercase;
text-align: center;
font-weight: normal;
letter-spacing: 10px;
font-size: 25px;
line-height: 1.5;
}
object{
width: 100%;
height: 100%;
display: block;
position: relative;
min-height: 100%;
}
/* Styles for Accordion */
.toggle{
background: #eee;
border-top: solid 1px #3b7c8e;
margin-bottom: 50px;
width: 80%;
height: 100%;
}
.toggle .toggle-title {
position: relative;
display: block;
margin-bottom: 6px;
}
.toggle .toggle-title h3 {
font-size: 20px;
margin: 0px;
line-height: 1;
cursor: pointer;
font-weight: 200;
}
.toggle .toggle-inner {
padding: 7px 25px 10px 25px;
display: none;
margin: -7px 0 6px;
max-width: 100%;
max-height: 100%;
min-height: 100%;
}
.toggle .toggle-inner div {
max-width: 100%;
max-height: 100%;
min-height: 100%;
}
.toggle .toggle-title{
display: block;
padding: 25px 25px 14px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="toggle">
<div class="toggle-title">
<h3>
<div class="title-name">Example title</div>
</h3>
<p>Example call for paper</p>
<p>Astronomers face an embarrassing conundrum: they don't know what 95% of the universe is made of. Atoms, which form everything we see around us, only account for a measly 5%. Over the past 80 years it has become clear that the substantial remainder is comprised of two shadowy entities – dark matter and dark energy. The former, first discovered in 1933, acts as an invisible glue, binding galaxies and galaxy clusters together. Unveiled in 1998, the latter is pushing the universe's expansion to ever greater speeds. Astronomers are closing.</p>
</div>
<div class="toggle-inner">
<object height="100" data="http://prototypes.infopro-insight.com/test/MW/call_for_papers.pdf"></object>
</div>
</div><!-- END OF TOGGLE -->

Can't click links due to overlapping divs

I have some overlapping divs in my design and my links are not clickable. I know the reason the links aren't clickable is because of said overlapping divs, so I assigned some z-indexes to try and combat that. However, I notice I can only make the links clickable by making the parent div (the one containing the div that actually houses my text) the highest z-index element... Which totally breaks my design and the way it looks. Is there a different way around this that I am not noticing? Or is this a case of having to redo the design completely?
The link to the journal skin I am working on.
I also want to throw a little edit in there mentioning that the side branches housed in the branchoverlay div are intended to overlap the other divs a little bit, see here. I have heard suggestions of removing them from their own div and putting them in the background of contentholder, but that would ruin that effect I think? Is there a better way to format that header/dropdown area to accomplish that slight overlay of the divs without having to do so much overlapping via negative margins?
HTML:
<div class="text"><div class="body">
<div class="menu"><div class="dropdowncontainer"><div class="dropdown">
<span><img src="https://s18.postimg.org/i8xcnc8gp/home.png"></span>
<div class="dropdown-content">
Bacon
Ribs
Steak
</div>
</div><div class="dropdown">
<span><img src="https://s9.postimg.org/iw9covwu7/guide.png"></span>
<div class="dropdown-content">
Bacon
Ribs
Steak
</div>
</div><div class="dropdown">
<span><img src="https://s12.postimg.org/aa9pluszh/resources.png"></span>
<div class="dropdown-content">
Bacon
Ribs
Steak
</div>
</div></div>
</div><div class="branchoverlay"></div><div class="contentholder">
<div class="maindiv"><p>Welcome and thank you for your interest in joining Hvalla, the following links have been provided for your convenience.
<h3>Required Reading</h3>
» The Rules — While you are not expected to commit these to memory, they are a required read.
» Setting and World Lore — An in-depth look at the world of Hvalla, from locations to the packs that inhabit it.
» Character Creation — All information pertaining to the creation of your character.
» How to Join — A detailed overview of the current joining process.
» Currency — An in-depth guide of Runestones and how to utilize them.
» FAQ — All frequently asked questions.
<hr>
<b>Core Concepts:</b>
<ul><li><span>Hvalla is a semi-realistic wolf art and roleplay community. Our goal is to stretch the boundaries of realism in a tasteful way, encouraging a more mature form of creativity in wolf RP. </span></li></ul><ul><li><span>We strive to provide a community that is inclusive and close-knit; no one should ever feel excluded, railroaded or otherwise on the fringes of a clique of close friends.</span></li></ul><ul><li><span>Characters in Hvalla may exhibit humanized aspects such as facial expressions and verbal communication similar to media such as Princess Mononoke, </span>The Jungle Book<span>, </span>Savva<span> etc., but overall should exhibit realistic behavior. </span></li></ul><ul><li><span class="bbcode_bold">Hvalla explores themes that are ideologically sensitive in nature.</span><span> We are always excited to involve new members in the community, however, if you find the exploration of dark themes such as murder, war, pillaging, abuse etc., to be outside of your comfort zone or you find yourself easily offended by aforementioned subjects, Hvalla may not be the community for you. Remember, this is creative writing, not real life.</span>
</li></ul></p></div></div>
<div class="rockfooter"></div> </div></div>
CSS:
/*BODY*/
.gr-body {
background: url(http://orig14.deviantart.net/8b57/f/2016/279/f/5/frontpagebackground_by_wulfghast-dak5apt.jpg);
background-size: 100%;
background-repeat: no-repeat;
background-color: #1c1119;
color: #545454;
}
.gr-top{
border: none;
margin: -5px 0px -10px 0px;
}
.gr-top img {
display: none;
}
h2 {
display: none;
}
.gr-top span {
display: none;
}
.tri {
display: none;
}
.gr1, .gr2, .gr3 {
display:none;
}
.bottom {
display: none;
}
.text {
margin-bottom: -38px;
padding: 0;
}
/*TEXT*/
p {
color: #3c281f;
font-family: 'montserrat', sans-serif;
font-size: 15px;
line-height: 1.4;
margin: 20px;
}
/*MENU AREA*/
.menu {
width: 64%;
height: 171px;
margin-left: auto;
margin-right: auto;
margin-top: 18%;
padding-left: 10%;
background: url('http://s15.postimg.org/zby726h7v/header.png');
background-repeat: no-repeat;
background-position: top-center;
background-size: 100% 70%;
position: relative;
z-index: 3;
}
.branchoverlay {
width: 74%;
height: 694px;
margin-left: auto;
margin-right: auto;
margin-top: -53px;
background: url('http://s15.postimg.org/n6ayvyzrd/branchoverlay.png');
background-repeat: no-repeat;
background-position: top-center;
background-size: 100% 70%;
position: relative;
z-index: 2;
}
.dropdowncontainer {
height: 30px;
width: 70%;
margin-left: auto;
margin-right: auto;
}
.dropdown {
position: relative;
display: inline-block;
width: 23%;
text-align: center;
margin-top: 30px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #4a463b;
min-width: 120px;
padding-bottom: 20px;
}
.dropdown-content a {
color: #ffffff;
line-height: 2.5;
}
.dropdown-content a:hover {
color: #000000;
}
.dropdown:hover .dropdown-content {
display: block;
}
/*CONTENT*/
.contentholder {
width: 68%;
margin-left: auto;
margin-right: auto;
margin-top: -735px;
-moz-box-shadow: 0 20px 20px 5px #0a0a0a;
-webkit-box-shadow: 0 20px 20px 5px #0a0a0a;
box-shadow: 0 20px 20px 5px #0a0a0a;
background-color: #50463b;
position: relative;
z-index: 1;
}
.maindiv {
width: 85%;
margin-top: 4%;
margin-left: 5%;
margin-bottom: 400px;
position: relative;
z-index: 5;
padding: 20px 20px 20px 20px;
display: inline-block;
}
/*FOOTER*/
.rockfooter {
background: url(http://s17.postimg.org/is79jxd3z/footer3_by_wulfghast_dakd92b_1.png);
height: 1000px;
width: 100%;
background-position: bottom;
background-repeat: no-repeat;
background-size: contain;
margin-left: auto;
margin-right: auto;
margin-top: -1100px;
position: relative;
z-index: 4;
}
/*RESPONSIVE MOBILE*/
.da-media[mobile] .menu {
width: 74%;
padding-left: 0%;
}
.da-media[mobile] .dropdown {
margin-top: 35px;
width: 31%;
}
.da-media[mobile] .maindiv {
margin-left: 1%;
}
.da-media[mobile] .rockfooter {
margin-top: -1300px;
}
Thanks for any help and suggestions anyone can give!
You got z-index:4 causing your div into front try making it to 1 or remove your margin-top
body div#devskin13122897 .rockfooter {
background: url(http://s17.postimg.org/is79jxd3z/footer3_by_wulfghast_dakd92b_1.png);
height: 1000px;
width: 100%;
background-position: bottom;
background-repeat: no-repeat;
background-size: contain;
margin-left: auto;
margin-right: auto;
margin-top: -1100px;
position: relative;
z-index: 1;
Please remove the branchoverlay div which is just used to hold a background image and add the image in contentholder class
background: #50463b url(http://s15.postimg.org/n6ayvyzrd/branchoverlay.png);
Check this url: jsfiddle.net/pfayap45