how can i add a newline or breakline on css - css

my code is in codepen how can i add breakline / new line between title and table ?
<li class="slide">
<H1>TITLE</H1>
<br />
<table border=1>
<tr>
<td>qdf</td>
<td>qdf</td>
</tr>
</table>
</li>
and css:
.slide {
width: 100%;
height: 100%;
flex: 1 0 100%;
display: flex;
justify-content: center;
align-items: center;
}

The default flex direction is row. Either you can remove the flex layout or make the flex-direction: column.
However, br is not the correct way to adjust spaces between flex items. Use properties like justify-content, gap, row-gap, column-gap
.slide {
width: 100%;
height: 100%;
flex: 1 0 100%;
justify-content: center;
display: flex;
flex-direction: column;
align-items: center;
}
<li class="slide">
<H1>TITLE</H1>
<br />
<table border=1>
<tr>
<td>qdf</td>
<td>qdf</td>
</tr>
</table>
</li>

<section class="slider-wrapper">
<button class="slide-arrow" id="slide-arrow-prev">
‹
</button>
<button class="slide-arrow" id="slide-arrow-next">
›
</button>
<ul class="slides-container" id="slides-container">
<li class="slide">
<h1 class="title">TiTLE</h1>
<table border=1>
<tr>
<td>qdf</td>
<td>qdf</td>
</tr>
</table> </li>
<li class="slide"></li>
<li class="slide"></li>
<li class="slide"></li>
</ul>
</section>
<footer>
Pen by Jemima Abu <span class="heart">♥</span>
</footer>
and use this css:
.slide {
/* width: 100%; */
height: 100%;
flex: 1 0 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

Related

I need centering flexbox columns in conteiner

My 3 images need to be in screen center. I use flexbox. After adding size to images all of them go to left. Also I can't throw off margin
This is what I need
This is what I have
My cod:
.collection {
list-style: none;
display: flex;
flex-direction: column;
align-items: center;
}
<ul class="collection">
<li><img class="col-img" src="images/bouquets.jpeg" alt=""><p class="col-text">Букети</p></li>
<li><img class="col-img" src="images/natural_flowers.jpeg" alt=""><p class="col-text">Живі квіти</p></li>
<li><img class="col-img" src="images/own_bouquet.png" alt=""><p class="col-text">"Свій" букет</p></li>
</ul>
This can be solved by absolutely positioning your p tag on top of your image. Use translate and top/left rules to move it to the center. Also make the a tag as display:block so it effectively covers the image. See below.
Edited:
There were a few small tweaks, the a tag had a 3 pixels below it which are space for descenders. This has been removed using line-height and means that images stack directly on top of each other. In the comments it was also stated that the images needed to be cropped and centered. This was done with display: flex on the anchor tag and then using align-self: center to prevent it from shrinking to the size of the parent div. Finally they were cropped using overflow:hidden. Now that the anchor tag is using flexbox the need to use inset and translate isn't needed as they center anyway.
Hope this helps
.collection {
list-style: none;
display: flex;
flex-direction: column;
align-items: center;
padding-left: 0;
}
a {
display: flex;
align-items: center;
justify-content: center;
position: relative;
color: white;
line-height:1;
height: 200px;
overflow: hidden;
box-shadow: 0px 0px 20px 2px #757575;
}
a p {
position: absolute;
background-color: #A6BFEA;
padding: 1rem 2rem;
margin: 0;
box-shadow: 0px 0px 20px 2px #757575;
line-height:normal;
}
img {
align-self:center;
translate: auto -50%;
}
<ul class="collection">
<li>
<a href="#">
<img class="col-img" src="https://placekitten.com/500/300" alt="">
<p class="col-text">Букети</p>
</a>
</li>
<li>
<a href="#">
<img class="col-img" src="https://www.fillmurray.com/500/300" alt="">
<p class="col-text">"Свій" букет</p>
</a>
</li>
<li>
<a href="#">
<img class="col-img" src="https://www.placecage.com/500/300" alt="">
<p class="col-text">"Свій" букет</p>
</a>
</li>
</ul>
.collection {
list-style: none;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
Something like this?
li {
margin-bottom: 3rem;
}
.collection {
list-style: none;
display: flex;
flex-direction: column;
align-items: center;
}
.container {
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
.container p {
position: absolute;
background: green;
color: white;
}
<ul class="collection">
<li>
<a href="#">
<div class="container">
<img class="col-img" src="https://dummyimage.com/300x150/000/fff" alt="">
<p class="col-text">Букети</p>
</div>
</a>
</li>
<li>
<a href="#">
<div class="container">
<img class="col-img" src="https://dummyimage.com/300x150/000/fff" alt="">
<p class="col-text">Букети</p>
</div>
</a>
</li>
<li>
<a href="#">
<div class="container">
<img class="col-img" src="https://dummyimage.com/300x150/000/fff" alt="">
<p class="col-text">Живі квіти</p>
</div>
</a>
</li>
</ul>

Underline table row but not content in it

I want to see effect like on screenshot below:
This is my code is at the moment:
table {
border-collapse: collapse;
}
table tr td {
border-bottom: 1px solid #000;
}
I can't figure out how not to underline content of TD but blank space only.
I would use flexbox for this, if that is ok with your browser compatibility.
<html>
<table>
<tr>
<td>
<div class="holder">
<div class="label">FooBar</div>
<div class="divider">
</div>
<div class="money">$1,000</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="holder">
<div class="label">FooBarFooBarFooBarFooBar</div>
<div class="divider">
</div>
<div class="money">$1,000</div>
</div>
</td>
</tr>
</table>
</html>
style:
.divider {
border-bottom: 1px solid black;
flex-grow: 1;
}
.holder {
display: flex;
flex-direction: row;
flex-wrap: no-wrap;
width: 500px;
justify-content: stretch;
}
.label, .money {
flex-grow: 0;
flex-basis: auto;
}
https://jsfiddle.net/pkyv8n5o/1/

Issue in IE11 with row (using flexbox) , doesn't stay beloow but covers the first row

In the footer I'm create a "grid". The problem is that in IE11, the row below, don't stay bellow like in Chrome/Firefox, but goes over the first row;
In IE11, the row with 'Term of use', 'All rights reserved" is the issue.
.footer {
display:flex;
flex-grow: 0;
margin: 1.5rem auto 1.5rem;
width: 100%;
flex-direction: column;
}
.footer > div {
align-items: flex-start;
flex-direction: row;
justify-content: space-between;
flex-basis: 100%;
display:flex;
}
.footer > :first-child {
margin: 1.5rem 0 0;
}
.navbar {
display: flex;
flex-direction: column;
align-items: flex-start;
}
<footer class="footer">
<div>
<div class="navbar">
<div class="items">
Lorem A
Lorem B
Lorem C
Lorem D
Lorem E
</div>
<div class="items">
Arcom A
Arcom B
Arcom C
</div>
</div>
<div class="action">
<button><span>AddFree</span></button>
</div>
<div class="email">
<form>
<input c name="email" placeholder="Email">
<p>Lorem ipsum arcom dolores.</p>
</form>
</div>
</div>
<div>
<div class="tpa">
<span>Term of Use</span>
<span>Privacy</span>
<span>About</span>
</div>
<div class="cop">LoremAll rights reserved.</div>
</div>
</footer>
IE 11 screenshot:
Please remove flex-basis property,
.footer>div {
align-items: flex-start;
flex-direction: row;
justify-content: space-between;
/**flex-basis: 100%;*/
display: flex;
}

Different result of css grid in Chrome and MS Edge

I'm pretty new at web dev so Im not really sure whats wrong here. Im using bootstrap grid. Here is the css:
body {
background: #252525;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: white;
height: 100%;
width: 100%;
overflow: auto;
margin: 0;
padding: 0;
}
html {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.grid-container {
display: grid;
overflow: auto;
height: inherit;
width: inherit;
}
.grid-container > * {
position: absolute
}
.login-box {
align-self: center;
justify-self: center;
width: 80%;
max-width: 450px;
min-width: 250px;
padding: 0;
}
HTML:
<div class="grid-container">
<div class="login-box container-fluid">
<div class="row">
<form id="frmLogin">
<div class="col-md-12 clear-margin-padding text-center">
<h4>Login to service</h4>
</div>
<div class="col-md-12 clear-margin-padding" style="margin-top: 10px;">
<table>
<col width="90">
<col width="*">
<tr>
<td>Email</td>
<td><input type="email" id="txtEmail" required></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" id="txtPassword" required></td>
</tr>
</table>
</div>
<div class="col-md-12 clear-margin-padding text-center" style="margin-top: 10px">
<div class="wrap-panel">
<button type="button" id="btnRegister">Register</button>
<button type="submit" id="btnLogin">Login</button>
</div>
</div>
</form>
<div class="col-md-12 clear-margin-padding text-center" style="margin-top: 5px">
Forgot my password
</div>
</div>
</div>
</div>
Im not sure who is wrong here but for sure it is caused by the
position: absolute;
What I want to accomplish is make the login box centered and when I want to add more 'box' to the grid-container, I can position them based on align-self and justify-self so the grid-container can act like WPF's Grid control.
Any help is appreciated.
Another example (same .grid-container):
HTML:
<div class="grid-container">
<div style="width:100px;height:100px;align-self:start;justify-self: left;background: black"></div>
<div style="width:100px;height:100px;align-self:center;justify-self: center;background: black"></div>
<div style="width:100px;height:100px;align-self:end;justify-self: right;background: black"></div>
</div>
MS Edge
Chrome
It turned out to be ms edge's fault I think because of position: absolute on my css code. I have managed to not use absolute positioning and everything is working good. Thanks for the help anyways! :)
To fix your problem just remove the display: grid from the grid container and display: flex and justify-content: center and align-items: center. Now the .grid-container should be as follows:
.grid-container {
display: grid;
justify-content: center;
align-items: center;
overflow: auto;
height: inherit;
width: inherit;
}
and remove align-self: center; justify-self: center; from your .login-box, that .login-box should be as follows:
.login-box {
width: 80%;
max-width: 450px;
min-width: 250px;
padding: 0;
}
you can find an updated fiddle here.
In general since you are not using CSS Grid, I would advise to drop display: grid as when targeting IE, using display: grid is not the most advised approach since the support is limited to IE 10+ and even then the support is partial and for an older specification of the grid for example justify-self justify-content align-self align-content are not supported or jaggy.
Feel free to ask any questions if anything is unclear.

get image and caption into one flex item?

AI want to put an image and its caption into one flex-item and have several such flex-items in one flex-container. I want the image to be above its caption. But what happens is that each caption is beside its image. How do I get them one above the other?
I tried putting the captions into another flex-container below the images. But when the screen size is less wide, the images stack, then the captions stack instead of being image, then its caption, image, then its caption.
<div class="flex-item-popup" id="popup">
<div class="close"><i class="fa fa-2x fa-times-circle"></i></div>
<h2></h2>
<div class='text'></div>
<div class="videos"></div>
<div class="flex-container images"></div>
<div class="flex-container captions"></div>
</div>
css:
#popup {
width: 90%;
height: auto;
padding: 20px;
border-radius: 10px;
background-color: black;
color: white;
}
#popup .close {
/*position: absolute;
right: 10px;
top: 10px;*/
float: right;
color: white;
opacity: 1;
}
#popup .close:hover {
opacity: .7 !important;
}
.images, .captions {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-content: flex-start;
align-items: flex-start;
}
.images {
margin-top: 20px;
}
.images .flex-item, .captions .flex-item {
display: flex;
flex-grow: 0;
flex-shrink: 0;
flex-basis: 300px;
}
Look into <figure> and <figcaption> HTML5 tags. I am pretty certain that is going to help you and it is what you are looking for.
Here is updated fiddle link.
And the SO code snippet here...
.flex-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-content: flex-start;
align-items: center;
}
.flex-item {
/*width: 350px;
height: null;*/
flex-grow: 1;
flex-shrink: 0;
flex-basis: 200px;
justify-content: flex-start;
display: flex;
padding-left: 20px;
}
.flex-item img {
cursor: pointer;
}
<div class="flex-container images">
<div class="flex-item">
<figure>
<img src="http://newsinteractive.post-gazette.com/hbcu/morehouse/img/grads.jpg" />
<!--<div style="clear: both;"></div>-->
<figcaption>Our grads.</figcaption>
</figure>
</div>
<div class="flex-item">
<figure>
<img src="http://newsinteractive.post-gazette.com/hbcu/morehouse/img/building.jpg" />
<figcaption>A building</figcaption>
</figure>
</div>
<div class="flex-item">
<figure>
<img src="http://newsinteractive.post-gazette.com/hbcu/morehouse/img/campus.jpg" />
<figcaption>The campus.</figcaption>
</figure>
</div>
<div class="flex-item">
<figure>
<img src="http://newsinteractive.post-gazette.com/hbcu/morehouse/img/trio.jpg" />
<figcaption>Three people</figcaption>
</figure>
</div>
</div>
Hope this helps

Resources