Expanding down? - html

So currently when I add a new entry to my kind of list it goes like this:
[entry] -> [new entry]
and then starts on the line beneath. How do I do so it first fills the first line straight down and then creates a second line and fills that one straight down.
To easier show what I mean. I will give every entry a number and show how it works.
How it works right now:
1 2
3 4
5 6...
And I want it to work like:
1 4
2 5
3 6
Anyone know how I should do?
Code comes here.
HTML
<div id="staffs">
<h5>The Management</h5>
<p>
<div class="staff_box">
<img src="/images/users/1.png" class="staff_img" />
<h3 class="staff_name">Sarah Doe <img src="/images/flags/Sweden-Flag-16.png" class="staff_country" /></h3>
<text class="staff_pos">CEO, Founder, Owner</text>
</div>
<div class="staff_box">
<img src="/images/users/1.png" class="staff_img" />
<h3 class="staff_name">David Doe <img src="/images/flags/Sweden-Flag-16.png" class="staff_country" /></h3>
<text class="staff_pos">CEO, Founder, Owner</text>
</div>
<!--Same boxes are repeated-->
</p>
</div>
CSS:
#staffs {
width: 530px;
height: 275px;
float: left;
clear: left;
overflow-y: hidden;
}
h5 {
text-align: center;
background: #222;
color: #888;
padding: 5px;
width: 510px;
font-weight: bold;
border-radius: 4px;
}
.staff_country {
height: 12px;
width: 12px;
}
.staff_box {
width: 175px;
height: 50px;
margin-left: 5px;
margin-top: 5px;
clear: left;
display: inline-block;
}
.staff_img {
height: 50px;
width: 50px;
float: left;
margin-right: 3px;
border-radius: 4px;
border: 1px solid #BBB;
}
.staff_name {
font-size: 13px !important;
margin: 0 !important;
padding: 0 !important;
padding-top: 2.5px !important;
}
.staff_pos {
font-size: 11px;
color: #777;
}
To see it in action, here is a JSFiddle: http://jsfiddle.net/7MfLU/4/
I would also need some help on how to move the top entries higher up, closer to the titlebar.

Probably the easiest way, since you're just using divs anyway, is to just reorder them in your HTML. You could also create two diva inside staff_box, a left and a right, and put your diva in the appropriate column that way. To move the entries closer to the title bar, change the margin-top to something smaller (you can go negative if you need to).

Related

Flex Layout Not Working as Intended With ngFor Loop

I searched but couldn't find a question quite like mine. Apologies if there's an answer somewhere.
I'm attempting to do a very simple flex layout in row format where 2 containers are side by side. I have a card component with an ngFor loop inside another component. Here's my code:
top-cta-HTML:
<section id="cta-container">
<h1>Take Control of Your Financial Future</h1>
<h4>
Whether you’re looking at annuities to guarantee future income, <br />save
for a life change, or selling your structured settlement,<br />
we’re here to help with guidance, advice, and experience
</h4>
<app-cta-card></app-cta-card>
</section>
top-cta-CSS:
#cta-container {
margin: 2.5rem 0 0 auto;
padding: 0 20px 0 5px;
background-color: orange;
width: 35%;
border-bottom-left-radius: 60px;
text-align: end;
}
#cta-container h1 {
font-size: 2.75rem;
font-weight: 900;
}
#cta-container h4 {
margin-top: -20px;
font-size: 1.2rem;
font-weight: 500;
line-height: 1.5em;
}
card-HTML:
<article id="card-parent-container">
<div class="top-cta-card" *ngFor="let card of ctaCards">
<div class="cta-card-topper">1</div>
<h3>{{ card.title }}</h3>
➔
<p>{{ card.description }}</p>
</div>
</article>
card-CSS:
.top-cta-card {
background-color: var(--cream);
width: 300px;
}
#card-parent-container {
display: flex;
flex-direction: column;
}
.cta-card-topper {
background-color: var(--teal);
height: 100%;
width: 100%;
color: var(--teal);
}
.top-cta-links {
background-color: var(--teal);
color: var(--cream);
padding: 5px 6px;
border-radius: 50%;
box-shadow: 3px 2px 3px var(--gunMetal50);
}
This code produces 2 cards stacked on top of each other and no matter what I change they won't sit in row format.
As a test, I made 2 divs inside the top-cta-HTML file with no ngFor loop and got the desired result. Any ideas here on what I'm doing wrong?
Thank you for any and all help, I really appreciate it!
So the issue was that my flex code was one layer too deep. I ended up putting the flex code on app-cta-card it the flex works as intended.
Here's the Stack Blitz code:
https://stackblitz.com/edit/angular-6oxcmy

divs on top of eachother not minding their margins

I have created several divs on top of each other .
Here is the problem that I'm having. The 2 divs in sessiondetails (sessionspeakers and sessionhosts) while they line up on top of themselves like I want them to, they don't listen to what I tell them to about padding. I want about 15px space between them, but they overlap eachother.
This is the html i am using:
<div class="sessiondetails">
<h3>Global Security Challenges and How We're Facing Them</h3>
Some of the biggest and most successful companies in the world depend on RSA's products and services for protection. Niloofar Howe, RSA's Chief Strategy Officer, is charged with making sure her company is responding to the needs of those customers by anticipating the next threat.<!-- Start of speaker list -->
<div class="sessionspeakers">
Speaker:<br><div class="speaker"><img src="http://www.structuresecurity.com/wp-content/uploads/2016/08/structuresecurityconf-niloo-howe.jpg" width="100px" height="100"><strong>Niloofar Howe</strong><br> Chief Strategy Officer, RSA</div>
</div> <!-- End of sessionspeakers list -->
<!-- Start of host list -->
<div class="sessionhosts">
Host:<br><strong>Mahendra Ramsinghani</strong>, Founder, Secure Octane
</div> <!-- End of sessionhosts list -->
</div>
This is my css:
.sessionentry {
width: 100%;
border-top: 1px solid grey;
border-top-color: grey;
border-bottom: 1px solid grey;
border-bottom-color: grey;
clear: both;
vertical-align: top;
overflow: hidden;
padding: 20px 0;
}
.sessiontime {
width: 15%;
float: left;
display: inline-block;
padding-left: 15px;
}
.sessiondetails {
width: 75%;
float: left;
display: inline-block;
}
.sessionmoderator, .sessionspeakers, .sessionhosts, .sessionemcee {
margin-top: 15px;
clear: both;
float: left;
}
.speaker {
overflow: visible;
display: block;
clear: both;
}
.speaker img {
float: left;
margin-right: 15px;
}
So can some kind soul please tell me what I did wrong?
Here are two images of the problem:
Sessionspeakers section doesn't go down far enough:
and then sessionhosts (div on bottom looks too high and covers part of photo)

CSS Code Help Needed

I'm looking to find out how to add another box inside my box which would be faded to act as a title bar for that specific box (If that makes sense)!
So basically, in the SOCIALBOX I'm looking to get a sub-faded bar at the top inside which would act as a title bar.
After a few comments of people saying they're not sure what I mean, I created a quick image in photoshop to act as some reference point.
Code Snippet:
body {
background: url("../images/backgroundimage.jpg") repeat 0 0;
}
/* CSS MENU BAR CODE GOES HERE */
#menubar {
width: 98.5%;
height: 40px;
background-color: #000000;
position: fixed;
border: 2px solid #ffffff;
}
.inside_text {
color: #FFFFFF;
float: right;
margin: 11px 7px 0 0;
}
.inside_text2 {
color: #FFFFFF;
float: left;
margin: 11px 0 0 7px;
}
/* CSS SOCIALBOX (RIGHT) GOES HERE */
#socialbox {
width: 40%;
height: 40%;
position: relative;
float: right;
margin: 0 8px 0 0;
background-color: #000000;
border: 2px solid #126b72;
}
<div id="menubar">
<div class="inside_text">
PLACEHOLDER TEXT
</div>
<div class="inside_text2">
PLACEHOLDER TEXT
</div>
</div>
<br />
<br />
<br />
<div id="socialbox">
</div>
So you are asking for a faded line within SOCIALBOX div, to serve as underline for a title?
If thats correct create another class
.title-bar
{
border-bottom:3px;
solid black;
opacity:0.3;
}
position with margin-left & margin-top values inside that class based on where you want it within SOCIALBOX.
for example:
.title-bar
{
border-bottom:3px;
solid black;
opacity:0.3;
margin-left:50px;
margin-top:30px;
float:left;
}
create a:
<div class="title-bar"></div>
and place that inside
<div id="socialbox"></div>
BTW make it a habit to use float:left when positioning divs with CSS, try to avoid position:absolute or fixed, unless absolutely necessary. It just comes out cleaner this way.

How do I put two divs next to each other?

I have been trying to put two divs next to each other, but I cannot find an effective way to do it. I want to set a sidebar menu next to an article. I tried floating one to the left, but all it does is create a huge gap between the two.
This is my code:
CSS
div#divone {
float:left;
margin-left: 10%;
border: 2px outset white;
padding; 10px 10px 10px 10px;
font-family; Times New Roman;
}
div#divtwo {
float:right;
margin-left: .1%;
border: 2px outset white;
padding; 10px 10px 10px 10px;
font-family; Times New Roman;
}
HTML
<div id="divone">
<p>word</p>
</div>
<div id="divtwo">
<p>word</p>
</div>
You can use float:left on the divs to bring them both together, and while you're doing that, why not put the common styles in one place, to make your CSS a little 'cleaner' ?
div.floated {
float: left;
border: 2px outset white;
padding: 10px 10px 10px 10px;
font-family: Times New Roman;
}
div#divone {
margin-left: 10%;
}
div#divtwo {
margin-left: .1%;
}
<body>
<div class="floated" id="divone">
<p>word</p>
</div>
<div class="floated" id="divtwo">
<p>word</p>
</div>
</body>
here's a jsfiddle to represent it if you want to play around with the code: http://jsfiddle.net/ya3L75xd/
You should put #divTwo { float:left }
Remove the float: left; on your div#divone.
Put the div#divtwo before the div#divone in the html.
Here's the solution:
http://jsfiddle.net/nk2oLvgy/1/
float:left; for both <div> and they are next to each other.

Align images next to each other

I'm having trouble getting these two images lined up where I want them - I'm trying to do a grid style-display but for some reason (despite using display: inline) the images are appearing on separate lines.
I tried editing the width of the "figure" element (since I guessed that was what the problem was) but it just shrunk everything down instead of what I wanted - could anyone help me out?
HTML
<div id="blade" class="tab-content">
<div id="simpleCart_shelfItem">
<figure>
<img src="http://i.imgur.com/abi4hJu.png" class="mini-img" />
<figcaption class="item_price">$17,000</figcaption>
<span class="item_name">Gomai Blade</span>
</figure>
</div>
<div id="simpleCart_shelfItem">
<figure>
<img src="http://i.imgur.com/IFAtrSy.png" class="mini-img" />
<figcaption class="item_price">$1,682</figcaption>
<span class="item_name">Gomai Blade</span>
</figure>
</div>
</div>
CSS
.mini-img {
width: 20%;
cursor: pointer;
}
.builder {
height: 20%;
text-align: center;
padding-bottom: 10px;
width: 50%;
}
.builder fieldset {
border: 1px solid black;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.builder fieldset legend {
text-align: left;
}
.tab-content {
margin-top: 10px;
}
.tab-content #simpleCart_shelfItem {
display: inline;
}
.tab-content #simpleCart_shelfItem .item_name {
display: none;
}
.tab-content #simpleCart_shelfItem figure {
width: auto;
}
I was trying to achieve a sort of "caption" effect under each separate image, but I still wanted the images lined up in a sort of "grid" format - I got the first part done (obviously) but it's the second part that's giving me trouble. I was hoping to avoid using a table, but I'm not sure if that would be more suited for this or not.
jsFiddle
I don't know what all that crazy code you've got is, but this is how I would do it. I understand you probably have all those classes for a reason, but could you consider simplifying, it will make your life easier, and make you a better coder.
HTML:
<div>
<img src="http://i.imgur.com/abi4hJu.png" class="mini-img" />
<p>$17 000</p>
</div>
<div>
<img src="http://i.imgur.com/IFAtrSy.png" class="mini-img" />
<p>$3500</p>
</div>
CSS:
div {
float: left;
margin: 10px;
}
p {
margin-top: 5px;
}
img {
width: 200px;
}
http://jsfiddle.net/eshellborn/g2xcr/18/
You are using the same ID for two DIV's which isn't valid HTML.
Can you instead of using percentages for your image tag use pixels instead. I changed the CSS to the below, adding float, and removing the other CSS.
.mini-img {
width: 100px;
cursor: pointer;
}
.tab-content {
margin-top: 10px;
}
div.simpleCart_shelfItem {
float: left;
}
JSFiddle Example:
http://jsfiddle.net/g2xcr/1/