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>
```
Related
I am using a semantic-ui framework. I am trying to make a post-comments like structure. currently my code looks like this:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.8/semantic.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.8/semantic.min.js"></script>
<title>Assignments</title>
<style>
.items {
width: 70%;
border: solid;
margin: 100px;
}
</style>
</head>
<body>
<div class="ui items">
<div class="item">
<a class="ui tiny image">
<img src="img_avatar3.png">
</a>
<div class="content">
<a class="header">Jenny Hess</a>
<div class="metadata">
<span class="date">Today at 5:42PM</span>
</div>
<div class="description">
<p>First Post Ever In My Life</p>
</div>
</div>
</div>
<div class="ui comments">
<div class="comment">
<a class="avatar">
<img src="img_avatar3.png">
</a>
<div class="content">
<a class="author">Matt</a>
<div class="metadata">
<span class="date">Today at 5:42PM</span>
</div>
<div class="text">
How artistic!
</div>
</div>
</div>
<div class="comment">
<a class="avatar">
<img src="img_avatar3.png">
</a>
<div class="content">
<a class="author">Elliot Fu</a>
<div class="metadata">
<span class="date">Yesterday at 12:30AM</span>
</div>
<div class="text">
<p>This has been very useful for my research. Thanks as well!</p>
</div>
</div>
</div>
<div class="comment">
<a class="avatar">
<img src="img_avatar3.png">
</a>
<div class="content">
<a class="author">Joe Henderson</a>
<div class="metadata">
<span class="date">5 days ago</span>
</div>
<div class="text">
Dude, this is awesome. Thanks so much
</div>
</div>
</div>
<form class="ui reply form">
<div class="field">
<textarea rows="3" cols="50"></textarea>
</div>
<div class="ui blue labeled submit icon button">
<i class="icon edit"></i> Add Reply
</div>
</form>
</div>
</div>
<div class="ui items">
<div class="item">
<a class="ui tiny image">
<img src="img_avatar3.png">
</a>
<div class="content">
<a class="header">Jenny Hess</a>
<div class="metadata">
<span class="date">Today at 5:42PM</span>
</div>
<div class="description">
<p>First Post Ever In My Life</p>
</div>
</div>
</div>
<div class="ui comments">
<div class="comment">
<a class="avatar">
<img src="img_avatar3.png">
</a>
<div class="content">
<a class="author">Matt</a>
<div class="metadata">
<span class="date">Today at 5:42PM</span>
</div>
<div class="text">
How artistic!
</div>
</div>
</div>
<div class="comment">
<a class="avatar">
<img src="img_avatar3.png">
</a>
<div class="content">
<a class="author">Elliot Fu</a>
<div class="metadata">
<span class="date">Yesterday at 12:30AM</span>
</div>
<div class="text">
<p>This has been very useful for my research. Thanks as well!</p>
</div>
</div>
</div>
<div class="comment">
<a class="avatar">
<img src="img_avatar3.png">
</a>
<div class="content">
<a class="author">Joe Henderson</a>
<div class="metadata">
<span class="date">5 days ago</span>
</div>
<div class="text">
Dude, this is awesome. Thanks so much
</div>
</div>
</div>
<form class="ui reply form">
<div class="field">
<textarea rows="3" cols="50"></textarea>
</div>
<div class="ui blue labeled submit icon button">
<i class="icon edit"></i> Add Reply
</div>
</form>
</div>
</div>
</body>
</html>
As you can see I have made items width 70% and margin auto but it doesn't center. Can someone suggest me why?
Give a specific id to parent of such item and give
text-align: center;
styling to it
Let me know if you require further help
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..
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;
}
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.
I have this code for making a cards stackable box. The problem is that this box is showing me a right paddding in the fragment, can anyone help me?
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" href="./semantic/semantic.css"/>
<title>Agora</title>
</head>
<body>
<div class="ui teal inverted menu" style="border-radius: 0px;">
<div class="item">
<div class="huge ui buttons">
<div class="ui button">One</div>
<div class="ui button">Two</div>
<div class="ui button">Three</div>
</div>
</div>
<div class="item">
<div class="ui button">Log-in</div>
</div>
</div>
<div class="ui column centered grid">
<div class="fourteen wide column">
<div class="ui center aligned segment">
<div class="ui stackable four column centered grid" >
<div class="column">
<div class="ui card">
<div class="image">
<img src="http://semantic-ui.com/images/avatar/large/elliot.jpg">
</div>
<div class="content">
<a class="header">Stevie Feliciano</a>
<div class="meta">
<span class="date">Joined in 2014</span>
</div>
<div class="description">
Stevie Feliciano is a library scientist living in New York City. She likes to spend her time reading, running, and writing.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
</div>
<div class="column">
<div class="ui card">
<div class="image">
<img src="http://semantic-ui.com/images/avatar/large/elliot.jpg">
</div>
<div class="content">
<a class="header">Stevie Feliciano</a>
<div class="meta">
<span class="date">Joined in 2014</span>
</div>
<div class="description">
Stevie Feliciano is a library scientist living in New York City. She likes to spend her time reading, running, and writing.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
</div>
<div class="column">
<div class="ui card">
<div class="image">
<img src="http://semantic-ui.com/images/avatar/large/elliot.jpg">
</div>
<div class="content">
<a class="header">Stevie Feliciano</a>
<div class="meta">
<span class="date">Joined in 2014</span>
</div>
<div class="description">
Stevie Feliciano is a library scientist living in New York City. She likes to spend her time reading, running, and writing.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
</div>
<div class="column">
<div class="ui card">
<div class="image">
<img src="http://semantic-ui.com/images/avatar/large/elliot.jpg">
</div>
<div class="content">
<a class="header">Stevie Feliciano</a>
<div class="meta">
<span class="date">Joined in 2014</span>
</div>
<div class="description">
Stevie Feliciano is a library scientist living in New York City. She likes to spend her time reading, running, and writing.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
This is the problem image:
http://imgur.com/1lrpbUL.png
I need to remove the padding that's in the right side.
Here is the working example:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui#2.4.2/dist/semantic.min.css">
<title>Agora</title>
<style type="text/css">
.ui.card {
margin: auto;
}
</style>
</head>
<body>
<div class="ui teal inverted menu" style="border-radius: 0px;">
<div class="item">
<div class="huge ui buttons">
<div class="ui button">One</div>
<div class="ui button">Two</div>
<div class="ui button">Three</div>
</div>
</div>
<div class="item">
<div class="ui button">Log-in</div>
</div>
</div>
<div class="ui column centered grid">
<div class="fourteen wide column">
<div class="ui center aligned segment">
<div class="ui stackable four column centered grid" >
<div class="column">
<div class="ui card">
<div class="image">
<img src="http://semantic-ui.com/images/avatar/large/elliot.jpg">
</div>
<div class="content">
<a class="header">Stevie Feliciano</a>
<div class="meta">
<span class="date">Joined in 2014</span>
</div>
<div class="description">
Stevie Feliciano is a library scientist living in New York City. She likes to spend her time reading, running, and writing.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
</div>
<div class="column">
<div class="ui card">
<div class="image">
<img src="http://semantic-ui.com/images/avatar/large/elliot.jpg">
</div>
<div class="content">
<a class="header">Stevie Feliciano</a>
<div class="meta">
<span class="date">Joined in 2014</span>
</div>
<div class="description">
Stevie Feliciano is a library scientist living in New York City. She likes to spend her time reading, running, and writing.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
</div>
<div class="column">
<div class="ui card">
<div class="image">
<img src="http://semantic-ui.com/images/avatar/large/elliot.jpg">
</div>
<div class="content">
<a class="header">Stevie Feliciano</a>
<div class="meta">
<span class="date">Joined in 2014</span>
</div>
<div class="description">
Stevie Feliciano is a library scientist living in New York City. She likes to spend her time reading, running, and writing.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
</div>
<div class="column">
<div class="ui card">
<div class="image">
<img src="http://semantic-ui.com/images/avatar/large/elliot.jpg">
</div>
<div class="content">
<a class="header">Stevie Feliciano</a>
<div class="meta">
<span class="date">Joined in 2014</span>
</div>
<div class="description">
Stevie Feliciano is a library scientist living in New York City. She likes to spend her time reading, running, and writing.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
It might be a problem that each of these cards do not fill the width of their column so they are aligned to the left.
You could use the class ".cards" which is mentioned here (it uses flexbox to fit the cards perfectly).
The code found in documentation:
<div class="ui cards">
<div class="card">
<a class="image">
<img src="/images/avatar/large/elliot.jpg">
</a>
<div class="content">
<a class="header">Elliot Fu</a>
<div class="meta">
<a>Friends</a>
</div>
<div class="description">
Elliot Fu is a film-maker from New York.
</div>
</div>
</div>
<div class="card">
<a class="image">
<img src="/images/avatar/large/helen.jpg">
</a>
<div class="content">
<a class="header">Helen Troy</a>
<div class="meta">
<a>Friends</a>
</div>
<div class="description">
Helen Troy is an archivist living in New York, who enjoys cooking, fine art, and gardening.
</div>
</div>
</div>
</div>