I am trying to build a website that uses the Twitch API and posts which users, from a predetermined array of 7 users, are online and which are not. It pretty much works, but at the moment, the edges of my top div are not lining up with the edges for my list of users.
Here's a link to the codepen: https://codepen.io/lieberscott/pen/YVZQMG
And here's some of my code.
HTML:
<div class="container-fluid">
<div class="row">
<div class="col-xs-3">
</div>
<div class="col-xs-6 head">
<span class="title">
Twitch Streamers
</span>
<table>
<tr>
<td id="all">ALL</td>
</tr>
<tr>
<td id="online">ONL</td>
</tr>
<tr>
<td id="offline">OFF</td>
</tr>
</table>
</div>
</div>
</div>
<div id="result">
</div>
</div>
CSS
$blue: #5D6E81;
$gray: #68636B;
$khaki: #B7D0B9;
$title: #F1EBF2;
img {
border-color: white;
border-radius: 50%;
border-style: solid;
border-width: 3px;
height: 50px;
margin-right: 25px;
width: 50px;
}
line {
background-color: $title;
height: 5px;
}
table {
float: right;
font-size: 10px;
margin-right: 6px;
}
.act {
background-color: $khaki;
margin: 1px 0px 1px 0px;
padding: 8px 8px 8px 15px;
}
.desc {
color: $gray;
padding-top: 20px;
}
.desc2 {
color: $title;
}
.head {
background-color: $gray;
color: $title;
font-size: 40px;
overflow: hidden;
padding: 15px 0px 10px 25px;
}
.inact {
background-color: $blue;
margin: 1px 0px 1px 0px;
padding: 8px 8px 8px 15px;
}
.inact a, inact a:hover {
color: $khaki;
}
.title {
font-family: 'Days One', sans-serif;
font-size: 40px;
}
Is there anything I can do with this existing code to make sure the width of the top div is aligned with the results? Or do I need to rework it?
(As a note, I did have it aligned with previous code using a single row and putting each result in a "col-xs-6 col-xs-offset-3" class, but this created another problem which was I couldn't make each result's img, user name, and status be vertically aligned with each other, which I would prefer.)
You accidentally closed your .container before the results. Remove the </div> immediately above the #results wrapper, paste it further down, and it all lines up: https://codepen.io/mayersdesign/pen/GmWyWy
Related
Why height text box is less than button?
My Code :
#container {
overflow: auto;
line-height: 100%;
border: 1px solid red;
}
.t,#but {
float: left;
}
#but ,.txt {
border: 1px solid #999;
padding: 10px;
font-size: 20px;
}
<div id="container">
<div class="t">
<input type="text" class="txt" name="">
</div>
<div id="but"><span>Search</span></div>
</div>
The <input> element, is one of the replaced elements, and In CSS, a replaced element is an element whose representation is outside the scope of CSS. It has some special styles from browser user agent stylesheet, and they don't get inherited by default, such as font-family, font-size, line-height etc., and those rules can determine a box's height.
You can force them to get inherited by setting <property>: inherit;, so that the <input type="text"> can inherit those styles from <div class="t"> and its parent <div id="container"> etc., so it will be able to get the same style as the <div id="but">, in order to make them the same height.
You can set those specific styles on the input box directly, but using inherit can prevent from overriding rules.
#container {
font-size: 20px;
overflow: auto;
}
.t,
#but {
float: left;
}
.txt {
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
.txt,
#but {
border: 1px solid #999;
padding: 10px;
}
<div id="container">
<div class="t">
<input type="text" class="txt" name="">
</div>
<div id="but"><span>Search</span></div>
</div>
In addition, you will use a <button> tag instead of <div> button in the real case I think. To make the input field and button the same height, you will also need to set the same padding values for them directly.
#container {
font-size: 20px;
overflow: auto;
}
.t,
#but {
float: left;
}
.txt,
#but {
font-family: inherit;
font-size: inherit;
line-height: inherit;
border: 1px solid #999;
padding: 10px;
}
<div id="container">
<div class="t">
<input type="text" class="txt" name="">
</div>
<button id="but"><span>Search</span></button>
</div>
Browser handles difference html element and attribute differently i check it computed tab in chrome developer tool and find out input field render height differently 1 px more in top and bottom so its 2 px actual height you set.
these line will fix your problem, check the snippet for how to apply them.
font-size:16px;
line-height:16px;
height:16px;
font-family:sans-serif;
#container {
overflow: auto;
line-height: 100%;
border: 1px solid red;
}
.t,#but {
float: left;
}
#but ,.txt {
border: 1px solid #999;
padding: 10px;
font-size:16px;
line-height:16px;
height:16px;
font-family:sans-serif;
}
<div id="container">
<div class="t">
<input type="text" class="txt" name="" placeholder="write a name" />
</div>
<div id="but"><span>Search</span></div>
</div>
/You'll need to do something like this although there is likely to be some differences across systems./
.searchtext {
border:1px solid #000;
border-right:none;
padding:4px;
margin:0px;
float:left;
height:16px;
overflow:hidden;
line-height:16px;
}
.searchbutton {
border:1px solid #000;
background:#fd0;
vertical-align:top;
padding:4px;
margin:0;
float:left;
height:26px;
overflow:hidden;
width:5em;
text-align:center;
line-height:16px;
}
Try giving font-size to all your elements, they will become of equal height.
#container {
overflow: auto;
line-height: 100%;
border: 1px solid red;
}
.t,
#but {
float: left;
}
#but,
.txt {
border: 1px solid #999;
padding: 10px;
font-size: 14px;
}
<div id="container">
<div class="t">
<input type="text" class="txt" name="">
</div>
<div id="but"><span>Search</span></div>
</div>
The problem is your font-size.
Please try to give font-size to all your elements like in the following fiddle:
#container {
overflow: auto;
line-height: 100%;
border: 1px solid red;
}
.t,
#but {
float: left;
}
#but,
.txt {
border: 1px solid #999;
padding: 10px;
font-size: 14px;
}
<div id="container">
<div class="t">
<input type="text" class="txt" name="">
</div>
<div id="but"><span>Search</span></div>
</div>
This is not valid selector:
line-height: 100%;
You have to define height to container, or wrap your inner content with:
.container .wrap{
position: relative;
display: inline-block;
width: 100%;
height: 100%;
}
And then set height: 100% to your #but element.
I have a search bar wrapped in a wrapper having background color. The search result is not visible as it is wrapped in the wrapper div. Now i want to somehow show the complete result. Also, i tried z-index but it did not help.
HTML:
<div class="col-md-12">
<div class="search_box_container">
<form>
<div class="col-md-10">
<input id="typeahead" type="text" data-provide="typeahead" class="form-control search_bar" name="search_bar" auto-complete="off">
</div>
<div class="col-md-2">
<button class="search_bar_button"></button>
</div>
</form>
</div>
</div>
CSS FOR WRAPPER:
.search_box_container{
padding: 0.5em;
background-color: #f0f0f0;
border-radius: 6px;
border:1px solid #DBDBDB;
position: relative;
overflow:hidden;
}
.search_bar{
height: 2.2em;
font-size: 1.45em;
color: black;
font-family: inherit;
}
.search_bar_button{
margin-top: 1px;
margin-left:-5px;
border-radius: 4px;
background: url('../img/search_bar_button.png') 0 0 no-repeat;
width: 5.2em;
background-position: 0px -2px;
height: 3.05em;
border: 2px solid #067b19;
}
JSFiddle
I want my p text to have a dotted line beneath it that spans the width of the text, I would also like the p to be centered horizontally.
The text never be longer than one line but it will vary in length on that line (if it was totally fixed, I could solve this easily).
I can't quite figure out the solution. I have the following structure:
<div class="container">
<div class="content">
<p>This is the title</p>
</div>
</div>
In my CSS, I have something like this:
.container {
width: 650px;
height: 100px;
}
.content {
text-align: center;
text-transform: uppercase;
font-size: 26px;
color: #4D4D4D;
}
p {
border-bottom: #808080;
border-bottom-width: thin;
border-bottom-style: dotted;
}
Here: http://jsfiddle.net/DqFp7/
HTML
<div class="container">
<div class="content">
<p>This is the title</p>
</div>
</div>
CSS
.container {
width: 650px;
height: 100px;
}
.content {
text-align: center;
text-transform: uppercase;
font-size: 26px;
color: #4D4D4D;
}
p {
border-bottom: #808080;
border-bottom-width: thin;
border-bottom-style: dotted;
display:inline;
}
You can use text-decoration couples with text-decoration-style, although support for this feature is still somewhat poor (Aug-2018: Not supported in Safari and Edge).
It's in the spec, so it will eventually be supported.
.
Example:
.container,
.content {
width: 100%;
}
.content p {
font-size: 30px;
text-decoration: underline;
text-decoration-style: dotted;
text-decoration-color: red;
text-align: center;
}
<div class="container">
<div class="content">
<p>This is the title</p>
</div>
</div>
I have implemented a facebook style search suggestion feature for my application . But , I am facing some issues here .
i) Below is the search box and the result div code :
<div align="right" style=" width:300px; float:right; margin-right:30px">
<input type="text" id="searchbox" class="searchbox" maxlength="100" style="color: rgb(170, 170, 170);"> <img src="../../../asset/images/search.png" style="margin:0 0 -5px 2px"><br><br>
<input type="hidden" value="http://www.plus-one-me.com/search/google/interests" id="formurl" name="formUrl">
<div id="display">
</div>
</div>
The search results get displayed within the #display div as below:
<div id="display" style="display: block;">
<div class="display_box" align="left"> Cakephp </div>
<div class="display_box" align="left"> Myspace </div>
<div class="display_box" align="left"> Php </div>
</div>
This is how the page looks before we enter anything in the search area :
Below is what the search results div is doing :
Basically , it brings down the menu in my main content area . So how can I fix this using CSS ?
Below are the styles :
of the menu div in the background (containing the options Home,History and Settings
.menuBar .submenu {
padding:4px 12px 5px 12px;
margin-right:8px;
border:2px solid #EEE;
text-decoration:none;
display:inline-block;
float:left;
font-size:13px;
-moz-border-radius:40px;
border-radius:40px;
-webkit-border-radius:40px;
-moz-box-shadow:0 1px 3px #777;
-webkit-box-shadow:0 2px 3px #777;
box-shadow:0 2px 3px #777;
color:#333;
background: -webkit-gradient(linear, 0 0, 0 70%, from(#765), to(#FFF));
background: -webkit-linear-gradient(#000, #FFF 70%);
background: -moz-linear-gradient(#BBB, #FFF 100%);
background: -ms-linear-gradient(#765, #FFF 70%);
background: -o-linear-gradient(#765, #FFF 1000%);
background: linear-gradient(#765, #FFF 70%);
-pie-background: linear-gradient(#765, #FFF 70%);
}
of my searchbox :
#searchbox {
border: 1px solid #000000;
padding: 3px;
width: 250px;
}
and the display_box for individual results :
.display_box {
border-top: 1px solid #DEDEDE;
font-size: 12px;
height: 30px;
padding: 4px;
}
the drop down menu has to have position:absolute applied to it. This takes it out of the flow of the page so it doesn't affect other elements.
As #Galen suggested, try css:
#display {
position: absolute;
}
You might want to instead have the html thats outputed be something more like
<ul id="display">
<li>result</li>
<li>result</li>
<li>result</li>
</ul>
Which if you did, you would have css along the lines of
#display {
position: absolute;
list-style-type: none; list-style: none;
margin: 0; padding: 0;
}
#display li {
display: block;
border-top: 1px solid #DEDEDE;
font-size: 12px;
height: 30px;
padding: 4px;
}
The situation: I have several lists; in each of these lists, the text inside the first li is positioned slightly to the right of center, instead of exactly in the center like the following li elements. In the following example, the second row text ("Site Map") is not centered. Any ideas?
The html:
<body>
<!-- <div class="header">Module Settings</div> -->
<div class="left_content">
<div id="header_nav" class="moduleTypeContent" style="top:-50px" name="header_nav">
<div class="moduleTypeHeader">
<div class="text-center">header_nav</div>
</div>
<ol class="connectedSortable sortable used nonest">
<li id="list_39">
<div class="listItemContents">
<div class="moduleTypeItem left">
<img src="common/images/icons/shadowed/cross-circle.png" alt="Delete Site Map" width="16" height="16" border="0" class="icon rightspace" />
</div>
<div class="moduleTypeItem center text-center">
Site Map
</div>
<div class="moduleTypeItem right text-center">
all
</div>
</div>
</li>
<li id="list_38">
<div class="listItemContents">
<div class="moduleTypeItem left">
<img src="common/images/icons/shadowed/cross-circle.png" alt="Delete Contact Us" width="16" height="16" border="0" class="icon rightspace" />
</div>
<div class="moduleTypeItem center text-center">
Contact Us
</div>
<div class="moduleTypeItem right text-center">
all
</div>
</div>
</li>
<li id="list_6">
<div class="listItemContents">
<div class="moduleTypeItem left">
<img src="common/images/icons/shadowed/cross-circle.png" alt="Delete Help" width="16" height="16" border="0" class="icon rightspace" />
</div>
<div class="moduleTypeItem center text-center">
Help
</div>
<div class="moduleTypeItem right text-center">
all
</div>
</div>
</li>
</ol>
</div>
</div>
and the relevant css:
html, body {
height:100%
}
body {
margin: 0px;
font-size: 12px;
font-family: Arial;
font-family: Arial, Verdana, Univers;
background-color: #f0eff0;
}
ol {
border: 0 solid #aeaeae;
border-width: 0;
margin: 0;
padding: 0;
padding-left: 30px;
}
ol.sortable, ol.sortable ol {
margin: 0 0 0 25px;
padding: 0;
list-style-type: none;
}
ol.sortable {
margin: 4em 0;
}
.sortable li {
margin: 0 0 0 0;
padding: 0;
}
.sortable li div {
border: 0 solid #aeaeae;
border-width: 1px;
padding: 0px;
margin: 0;
cursor: move;
}
div.moduleTypeDiv {
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 12px;
width:100%;
}
div.moduleTypeHeader {
border:1px solid #6d6d6d;
padding: 6px;
}
div.moduleTypeHeader {
background: #336699 url(../images/table_header_highlight.png) repeat-x bottom;
font-weight:bold;
color: #ffffff;
}
div.moduleTypeHeader a {
color: #ffffff;
}
.left_content{
width:48%;
float: left;
}
.moduleTypeContent{
position:relative;
top: -50px;
}
.moduleTypeHeader{
position: relative;
bottom: -48px;
}
.legendItem.left, .moduleTypeItem.left{
float: left;
width: 18px;
padding: 5px;
border:0px ;
border-right: 1px solid #aeaeae;
}
.legendItem.center, .moduleTypeItem.center {
padding:6px;
border:0px ;
}
.legendItem.right, .moduleTypeItem.right {
position: relative;
top: -25px;
float: right;
width: 100px;
padding:6px;
width:50px;
border:0px ;
border-left: 1px solid #aeaeae;
}
.listItemContents {
position:relative;
}
.text-center { text-align:center; }
Thanks!
p.s. I created a fiddle: http://jsfiddle.net/earachefl/c2bcc/
You are doing some really weird positioning on the right "column" elements by floating the right, but not actually leaving them any space for them on the line they belong, so they are pushed down a row and then using relative positioning is "hack" them back where you want them. And thus there is no item in the first line that would push the text left so that it would appear centered.
Simple solution: Use a table. Your code is a prime example of bad "CSS hacking" because of misunderstanding the rule "Don't use tables for layout". Please, use a table. Please.
EDIT:
Since you can't use a table, here's what you have to do:
Move the "right" column to the first position in the list item
Give the center column a right margin wide enough for the right column to fit it. (63px = 50px width + 2 * 6px padding + 1px left-border)
http://jsfiddle.net/Se87U/1/