How to align 2 blocks in the center in semantic ui? - html

For my project (semantic ui) I want to align 2 blocks. Both blocks should be displayed in the horizontal center of the page. Block 1's width is not important since its a small block. Blocks 2 should be 12 columns wide. How can I do this?
Block 1:
<img class="ui small circular image" src="images/large/stevie.jpg">
<h1>Stevie Wonder</h1>
<p>#stevie</p>
<p>Amsterdam, The Netherlands</p>
<button class="ui button">Edit Profile</button>
Block 2:
<div class="ui top attached tabular menu">
<div class="active item">My Bla's</div>
<div class="item">Favorite Bla's</div>
</div>
<div class="ui bottom attached tab segment">
<div class="ui divided items">
<div class="item">
<div class="image">
<img src="/images/wireframe/image.png">
</div>
<div class="content">
<a class="header">12 Years a Slave</a>
<div class="meta">
<span class="cinema">Union Square 14</span>
</div>
<div class="description">
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
Full code:
<div class="ui main container">
<div class="row">
<div class="column">
<img class="ui small circular image" src="images/large/stevie.jpg">
<h1>Stevie Wonder</h1>
<p>#stevie</p>
<p>Amsterdam, The Netherlands</p>
<button class="ui button">Edit Profile</button>
</div>
</div>
<div class="row">
<div class="column">
<div class="ui top attached tabular menu">
<div class="active item">My Bla's</div>
<div class="item">Favorite Bla's</div>
</div>
<div class="ui bottom attached tab segment">
<div class="ui divided items">
<div class="item">
<div class="image">
<img src="/images/wireframe/image.png">
</div>
<div class="content">
<a class="header">My Neighbor Totoro</a>
<div class="meta">
<span class="cinema">IFC Cinema</span>
</div>
<div class="description">
<p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

make one common div for block1 and block 2
apply css.
html:
<div class="main">
<div class="block1">---</div>
<div class="block2">---</div>
</div>
css:
.main
{
width:suitable size(block1+block2) in pixel
margin:0 auto;
}
.block1
{
width:block1's width;
float:left;
}
.block2
{
width:block2's width;
float:right;
}

Related

float property ignores margin

I am learning semantic-ui framework and currently I'm using segments. My code looks like this:
<!DOCTYPE html>
<html>
<head>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.css">
<script
src="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.js"></script>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<title>Assignments</title>
<style>
.raised.segment{
margin: 1.5%;
width: 30%;
display: inline-block;
float: left;
}
h3 {
display: inline-block;
text-align: center;
}
</style>
</head>
<body>
<div class="ui raised segment">
<h2 class="ui header">
Section 6
</h2>
<div class="ui middle aligned selection list">
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/helen.jpg">
<div class="content">
<h3 class="ui header"> Vasil Pkhakadze </h3>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
</div>
</div>
<div class="ui raised segment">
<h2 class="ui header">
Section 6
</h2>
<div class="ui middle aligned selection list">
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/helen.jpg">
<div class="content">
<h3 class="ui header"> Vasil Pkhakadze </h3>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
</div>
</div>
<div class="ui raised segment">
<h2 class="ui header">
Section 6
</h2>
<div class="ui middle aligned selection list">
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/helen.jpg">
<div class="content">
<h3 class="ui header"> Vasil Pkhakadze </h3>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
</div>
</div>
<div class="ui raised segment">
<h2 class="ui header">
Section 6
</h2>
<div class="ui middle aligned selection list">
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/helen.jpg">
<div class="content">
<h3 class="ui header"> Vasil Pkhakadze </h3>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
<div class="item">
<img class="ui avatar image" src="/images/avatar/small/christian.jpg">
<div class="content">
<div class="header">George Cercvadze</div>
</div>
</div>
</div>
</div>
</body>
</html>
Everything is fine except the first segment. float:left property ignores its margin and so the first segment is touching the borders. Other segments are fine. Any suggestions ?
Class with .ui.segment:first-child{margin-top: 0;} in semantic.min.css
have margin-top:0; thus making it to touch borders, override it with custom css
add important tag to this rule
CSS
.raised.segment{
margin: 1.5% !important;
width: 30%;
display: inline-block;
float: left;
}
everything should work fine
Link For reference
hope this helps..

Semantic UI : how to place an button at the bottom of a column?

This is a very simple question, but after some research, I can't find a way to do it properly: I have a grid with 3 columns in Semantic UI and the content of each column has a specific height. I try to add a button at the bottom of each column, but "bottom aligned" doesn't work.
Someone has a clue ?
Here is an example:
<div class="ui basic segment">
<div class="ui divided grid container">
<div class="three column row">
<div class="column">
Hello <br>
fdsfsd <br>
fsfsd <br>
fdsfsd <br>
fsfsd <br>
fsfsd <br>
fdsfsd <br>
fsfsd <br>
fs
</div>
<div class="column">
<div class="segments">
<div class="ui segment">Hello</div>
<div class="ui bottom aligned segment">
fdsfsdf
</div>
</div>
</div>
<div class="column">
Hello
</div>
</div>
</div>
</div>
Thanks for your help !
One way to go about it is to use a flexbox inside the column to position the content and the .ui.segment div
JS Fiddle: https://jsfiddle.net/batrasoe/vq84trys/4/
<div class="ui segment">
<div class="ui divided grid container">
<div class="three column stretched row">
<div class="column">
<div class="segment-wrapper">
<div class="content">
</div>
<div class="ui bottom segment">
</div>
</div>
</div>
<div class="column">
<div class="segment-wrapper">
<div class="content">
</div>
<div class="ui bottom segment">
</div>
</div>
</div>
<div class="column">
<div class="segment-wrapper">
<div class="content">
</div>
<div class="ui bottom segment">
</div>
</div>
</div>
</div>
</div>
</div>
And CSS:
.segment-wrapper {
background-color: #DDD;
display: flex;
flex-direction: column;
}
.content {
flex: 1;
background-color: skyblue;
}
.ui.bottom.segment {
margin-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
}

How to put semantic ui items into segments in html?

I would like to put each semantic ui item into a segment. Whats the right way to do this in semantic ui / html? Should I put item inside segment, segment inside item, or neither?
Items
Items code:
<div class="ui divided items">
<div class="item">
<div class="image">
<img src="/images/wireframe/image.png">
</div>
<div class="content">
<a class="header">12 Years a Slave</a>
<div class="meta">
<span class="cinema">Union Square 14</span>
</div>
<div class="description">
<p></p>
</div>
<div class="extra">
<div class="ui label">IMAX</div>
<div class="ui label"><i class="globe icon"></i> Additional Languages</div>
</div>
</div>
</div>
<div class="item">
<div class="image">
<img src="/images/wireframe/image.png">
</div>
<div class="content">
<a class="header">My Neighbor Totoro</a>
<div class="meta">
<span class="cinema">IFC Cinema</span>
</div>
<div class="description">
<p></p>
</div>
<div class="extra">
<div class="ui right floated primary button">
Buy tickets
<i class="right chevron icon"></i>
</div>
<div class="ui label">Limited</div>
</div>
</div>
</div>
<div class="item">
<div class="image">
<img src="/images/wireframe/image.png">
</div>
<div class="content">
<a class="header">Watchmen</a>
<div class="meta">
<span class="cinema">IFC</span>
</div>
<div class="description">
<p></p>
</div>
<div class="extra">
<div class="ui right floated primary button">
Buy tickets
<i class="right chevron icon"></i>
</div>
</div>
</div>
</div>
</div>
Segment:
Segment code:
<div class="ui segment">
</div>
Semantic UI Items and Segments are not designed to work together (i just ran into this same issue) so my workaround was to add the requisite css to my stylesheet applied to a .ui.segment.item element (you could also place this into the scss templates and use scss variables for colors, spacing, etc. instead to compile this into a custom build of semantic-ui for your site).
So then you can apply both .item and .segment styles to those blocks that you want to have both styles (for any variations like piled or compact, you would have to include those variations as custom styles too of course).
I did it this way because the styles for a segment are fairly self contained, but the ones for an item are quite extensive, so they would be harder to reproduce accurately.
The built in code runner doesn't seem to display correctly, so here is a fiddle with the same code working correctly: https://jsfiddle.net/nw8nte4b/
```
.ui.segment.item {
position: relative;
background: #fff;
box-shadow: 0px 1px 2px 0 rgba(34, 36, 38, 0.15);
margin: 1rem 0;
padding: 1em;
border-radius: 0.25rem;
border: 1px solid rgba(34, 36, 38, 0.15);
}
<link href="https://oss.maxcdn.com/semantic-ui/2.2.4/semantic.min.css" rel="stylesheet" />
<div class="ui centered padded grid">
<div class="ten wide column">
<div class="ui items">
<div class="ui item segment">
<div class="image">
<img src="http://semantic-ui.com/images/wireframe/image.png">
</div>
<div class="content">
<a class="header">12 Years a Slave</a>
<div class="meta">
<span class="cinema">Union Square 14</span>
</div>
<div class="description">
<p></p>
</div>
<div class="extra">
<div class="ui label">IMAX</div>
<div class="ui label"><i class="globe icon"></i> Additional Languages</div>
</div>
</div>
</div>
<div class="ui item segment">
<div class="image">
<img src="http://semantic-ui.com/images/wireframe/image.png">
</div>
<div class="content">
<a class="header">My Neighbor Totoro</a>
<div class="meta">
<span class="cinema">IFC Cinema</span>
</div>
<div class="description">
<p></p>
</div>
<div class="extra">
<div class="ui right floated primary button">
Buy tickets
<i class="right chevron icon"></i>
</div>
<div class="ui label">Limited</div>
</div>
</div>
</div>
<div class="ui item segment">
<div class="image">
<img src="http://semantic-ui.com/images/wireframe/image.png">
</div>
<div class="content">
<a class="header">Watchmen</a>
<div class="meta">
<span class="cinema">IFC</span>
</div>
<div class="description">
<p></p>
</div>
<div class="extra">
<div class="ui right floated primary button">
Buy tickets
<i class="right chevron icon"></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
```

Customizing bootstrap grid

I need to design grid using bootstrap, like in the picture that I have uploaded.Please help me.
I think something along the lines of
<div class="col-sm-4">
<div class="content-here">
<img src="img1.jpg" />
</div>
</div>
<div class="col-sm-8">
<div class="boxes">
Box 1
</div>
<div class="boxes">
Box 2
</div>
<div class="boxes">
Box 3
</div>
<div class="boxes">
Box 4
</div>
</div>
CSS
.content-here { height: 400px; }
.boxes { float:left; width:50%; height:200px; }
The grid system code might look like this :
<div class="row">
<div class="col-sm-4">
<img src="example.jpg">
</div>
<div class="col-sm-4">
<div class="col-sm-12">
<img src="example.jpg">
</div>
<div class="col-sm-12">
<img src="example.jpg">
</div>
</div>
<div class="col-sm-4">
<div class="col-sm-12">
<img src="example.jpg">
</div>
<div class="col-sm-12">
<img src="example.jpg">
</div>
</div>
</div>
After that, you can specify the width and height of each image. If you want your image to take a full width (means taking all space of the column), you can set width:100%.

Semantic UI equal height columns

I found "equal height" classes in Semantic UI, but I can't make inner div's the same heights ("ui segment" for example).
More detail here .
http://jsfiddle.net/ozk615p6/34/
Check my below Screenshots
<div class="ui container indent border shadow">
<div class="two column stackable ui grid ">
<div class="equal height row">
<div class="column">
<h2 class="ui header center aligned ">Lorem</h2>
<div class="ui segment ">
<div class="ui list ">
<div class="item">
<i class="checkmark icon"></i>
<div class="content">
Lorem
</div>
</div>
<div class="item">
<i class="xmark icon"></i>
<div class="content">
Lorem
</div>
</div>
</div>
</div>
</div>
<div class="column">
<h2 class="ui header center aligned ">Lorem</h2>
<div class="ui segment ">
<div class="ui list">
<div class="item">
<i class="checkmark icon"></i>
<div class="content">
Lorem
</div>
</div>
<div class="item">
<i class="checkmark icon"></i>
<div class="content">Lorem</div>
</div>
<div class="item">
<i class="checkmark icon"></i>
<div class="content">Lorem</div>
</div>
<div class="item">
<i class="xmark icon"></i>
<div class="content">Lorem</div>
</div>
<div class="item">
<i class="xmark icon"></i>
<div class="content">Lorem</div>
</div>
<div class="item">
<i class="xmark icon"></i>
<div class="content">Lorem</div>
</div>
<div class="item">
<i class="xmark icon"></i>
<div class="content">Lorem</div>
</div>
</div>
</div>
</div>
</div>
One approach is to use ui cards per this documentation. In your JSFiddle attached, the version did not yet support equal hight cards which automatically used flex. If you upgrade to latest, you'll obtain support for this.
See an example here: https://jsfiddle.net/5kL2pf7q/1/
According to this post, one possible solution is to use this to match the height of your columns.
Although writing html with just the Semantic UI classes in the code below:
<div class="ui container">
<div class="ui three column doubling stackable grid container">
<% camps.forEach(function (e) { %>
<div class="column">
<h1 class="ui header"><%= e.name %> </h1>
<img src="<%= e.image %>" alt="" class="image small ui">
<p> <%= e.description %></p>
<div class="extra"><div class="ui label">
Read More
</div></div>
</div>
<% }) %>
</div>
</div>
I realized that the columns are already with the same height as you can see here.