I am working on creating a custom tooltip plug-in and am having trouble with the CSS and HTML layout of it.
I would like to have something like this:
Nested inside some div container.
Here is a JSFiddle of what I have at the moment, but as you can see - I'm having some issues.
Thanks to all you CSS gurus!
Here is the updates JSFiddle I made for you: http://jsfiddle.net/Y2E36/2/ All I did was add Display:inline-block; to status-icons
Here is a basic re-creation for you.
Fixed h2 closing tag
Have a jsbin example!
HTML
<div class="contact">
<img src="http://www.placehold.it/100X120/FFFFFF" />
<div class="actions">
</div>
<div class="details">
<h1>John Smock</h1>
<h2>In since Thursday, 5/9/2013 at 9:45 AM</h2>
<p><span>Lync (Away 5 Min)</span> Lenexa</p>
</div>
</div>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Helvetica;
}
.contact {
height: 120px;
width: 450px;
background: #ccc;
border-top: solid 1px #000;
}
.contact img {
border-left: solid 12px orange;
border-right: solid 1px #000;
float: left;
}
.actions {
float: left;
border-right: solid 1px #000;
margin: 0 10px 0 0
}
.actions a {
background: url(http://www.placehold.it/20/FFFFFF) no-repeat;
width: 20px;
height: 20px;
display: block;
margin: 15px 13px;
border: none;
}
.details h1 {
font-size: 1em;
padding: 8px 0 5px;
}
.details h2 {
font-size: 0.8em;
font-weight: normal;
padding: 3px;
}
.details p {
font-size: 0.8em;
margin: 48px 0 0;
}
.details span {
padding: 0 5px 0 0;
border-right: solid 1px #000;
}
Related
I have been trying to get three bits of text (styled to look like buttons) to line up left, centre, and right using HTML and CSS, no Flexbox or JS, but without success. How can this be achieved? This is what I need:
Here is my code:
#row1 {padding: 20px 20px 5px 20px;
overflow: hidden; }
.button-container {display: block; text-align: center;}
.button-left {
padding: 0 5px;
text-align: center;
border: 1px solid;
float: left;
font-size: 75%; }
.button-right {
padding: 0 5px;
text-align: center;
border: 1px solid;
float: right;
font-size: 75%; }
.button-centre {
padding: 0 5px;
text-align: center;
border: 1px solid;
font-size: 75%; }
<div id="row1">
<div class="button-container">
<span class="button-left">previous</span>
<span class="button-centre">issue</span>
<span class="button-right">next</span>
</div><!--close button-container">
</div><!--close r1-->
Flexbox is ideal for this type of a problem:
#row1 {
padding: 20px 20px 5px 20px;
overflow: hidden;
}
.button-container {
display: flex; /* displays flex-items (children) inline */
justify-content: space-between; /* MDN: The items are evenly distributed within the alignment container along the main axis. The spacing between each pair of adjacent items is the same. */
align-items: center; /* centers them vertically */
}
.button-left {
padding: 0 5px;
text-align: center;
border: 1px solid;
font-size: 75%;
}
.button-right {
padding: 0 5px;
text-align: center;
border: 1px solid;
font-size: 75%;
}
.button-centre {
padding: 0 5px;
text-align: center;
border: 1px solid;
font-size: 75%;
}
<div id="row1">
<div class="button-container">
<span class="button-left">previous</span>
<span class="button-centre">index</span>
<span class="button-right">next</span>
</div>
</div>
Alternative without Flexbox:
* {margin: 0; padding: 0; box-sizing: border-box}
#row1 {padding: 20px 20px 5px 20px}
.button-container {position: relative}
.button-left {
position: absolute;
left: 0;
padding: 0 5px;
text-align: center;
border: 1px solid;
font-size: 75%; }
.button-right {
position: absolute;
right: 0;
padding: 0 5px;
text-align: center;
border: 1px solid;
font-size: 75%; }
.button-centre {
position: absolute;
left: calc(50% - 17px);
padding: 0 5px;
text-align: center;
border: 1px solid;
font-size: 75%; }
<div id="row1">
<div class="button-container">
<span class="button-left">previous</span>
<span class="button-centre">issue</span>
<span class="button-right">next</span>
</div>
</div>
Changes made: .button-container {position: relative}, also added position: absolute to all the children with appropriate values of the left and right properties, for the middle child the value of the left property calc(50% - 17px) is calculated based on it's width (padding and border included) which is 34px divided by 2 and deducted from 50%.
HTML
<div id="row1">
<div class="button-container">
<span class="button">previous</span>
<span class="button">index</span>
<span class="button">next</span>
</div><!--close button-container">
</div><!--close r1-->
CSS
#row1 {
padding: 20px 20px 5px 20px;
overflow: hidden;
}
.button-container {display: block; text-align: center;}
.button {
padding: 0 5px;
text-align: center;
border: 1px solid;
font-size: 75%; }
You can use Flexbox, assuming you just want all the buttons to be next to each other you can give your .button-container the property display:flex;.
Here's a JSFiddle.
Your button container is already a block level element, since you are using a <div> so you don't need the display:block
.btns {
position: relative;
display: inline-block;
font-size: 0;
}
.btns a {
position: relative;
display: inline-block;
text-decoration: none;
background-color: #F4F4F4;
color: #000;
font-size: 14px;
padding: 5px 15px;
transition: all .3s ease-in-out;
}
.btns a:hover {
background-color: #777;
color: #FFF;
}
.btns a:first-child {
border-radius: 10px 0 0 10px;
border-right: 1px solid #CCC;
}
.btns a:last-child {
border-radius: 0 10px 10px 0;
border-left: 1px solid #CCC;
}
<div class="btns">
Previous
Index
Next
</div>
Simplest way would be to just add a <br>tag after each button, line this:
<div id="row1">
<div class="button-container">
<span class="btns button-left">previous</span>
<br>
<span class="btns button-centre">index</span>
<br>
<span class="btns button-right">next</span>
<br>
</div><!--close button-container">
</div><!--close r1-->
I'm trying to create a text box mixture of HTML/CSS. I have CSS code for designing of text box. I want to use this code in blogger but I'm unable to combine the CSS in one class so that use in blogger. Someone help me please. Thanks.
CSS and HTML:
body {
background-color: #f1f1f1;
font-family: Helvetica,Arial,Verdana;
}
.link-box,.link-wrapper {
position: relative;
padding: 10px;
}
.link-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.link-box {
width: 80%;
border: 1px solid #ccc;
outline: 0;
border-radius: 15px;
}
.link-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 1px solid #0AA700;
}
<div class="link-wrapper">
<input type="text" onClick="this.select();" name="focus" required class="link-box" value="www.google.com" readonly/>
</div>
Not entirely what you mean by one class. But if you mean you can only have a class on the parent div and not on the input, this would work.
.link-wrapper {
position: relative;
width: 500px;
margin: auto;
margin-top: 50px;
padding: 10px;
}
.link-wrapper input {
width: 80%;
border: 1px solid #ccc;
outline: 0;
border-radius: 15px;
padding: 10px;
}
.link-wrapper input:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 1px solid #0AA700;
}
I've got a few div elements that aren't expanding to match the height of their content. I have read that this can be caused by float-ed content; This content isn't float-ed - although I am beginning to feel like I should throw my computer in a river. Does that count?
code:
#interaction-options-container.display-dialogue {
left: 15%;
width: 70%;
}
#interaction-options-container.full-border, .dialogue-container.full-border {
border: 1px solid #33ffff;
}
#interaction-options-container {
margin: 4px 0px 4px 0px;
z-index: 100;
position: absolute;
left: 35%;
bottom: 4%;
width: 30%;
line-height: 1.4;
opacity: 0.75;
}
#interaction-options-container .heading {
font-size: 16px;
color: black;
padding: 0.1px 12px 0.1px 12px;
background-color: grey;
}
.heading {
font-weight: bold;
font-size: 1.5em;
padding: 8px 12px 0px 12px;
}
#interaction-options-container p {
margin: 8px 0px 8px 0px;
}
#interaction-options-container .dialogue p {
margin: 4px 0px 4px 0px;
}
#interaction-options-container .button, #interaction-options-container .evidence-options-container .button {
cursor: pointer;
color: white;
font-size: 14px;
padding: 0.1px 12px 0.1px 12px;
background-color: #333333;
opacity: 0.85;
border-bottom: 1px solid #8d8d8d;
}
#interaction-options-container .dialogue-container {
padding: 0px;
margin: 0px;
width: 100%;
height: 32px;
background-color: #333333;
float: none;
}
#interaction-options-container .dialogue {
text-align: center;
margin: auto;
font-size: 16px;
font-weight: bold;
padding: 1px 12px 1px 12px;
color: white;
background-color: #333333;
}
.dialogue-container .dialogue.option-divider {
border-bottom: 1px solid #333333;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
<div class="hud-element display-dialogue full-border" id="interaction-options-container">
<div class="heading"><p>Choose a reply:</p></div>
<div class="dialogue-container button">
<div class="dialogue option-divider"><p>Option one here</p></div>
</div>
<div class="dialogue-container button">
<div class="dialogue option-divider"><p>Option two here</p></div>
</div>
<div class="dialogue-container button">
<div class="dialogue option-divider"><p>Option three here</p></div>
</div>
<div class="dialogue-container button">
<div class="dialogue"><p>Option four here. As an example this text should be long enough to require wrapping to a new line. I will therefore have to keep typing until I've added enough text to sufficiently fill the horizontal with of the containing div. Also, thanks for potentially answering my question, which I will get to below...</p></div>
</div>
</div>
The problem is, when a piece of dialogue requires wrapping to a new line, the .dialogue-container .button div does not expand in height to match the height of the .dialogue div. The inner divs therefore extend past the border lines, which looks bad.
If anyone has any pointers, my computer will thank you.
Cheers.
#interaction-options-container .dialogue-container {
padding: 0px;
margin: 0px;
width: 100%;
//height: 32px;
background-color: #333333;
float: none;
}
I'm trying to achieve the effect of having a centered image that flows past its containing div's borders, but without using position: absolute, because it hides the header buttons behind it. Is there any clean way to do this without just using old-school absolute position with all the elements (which would be a real pain if I try to do any kind of responsiveness at all)?
Relevant code:
.container {
max-width: 60rem;
margin: 0 auto;
padding: 3rem 1.5rem;
border-right: 1px solid black;
border-left: 1px solid black;
background-color: white;
}
.container.no-border {
border: none;
background-color: transparent;
position: relative;
}
#logo {
display: block;
position: absolute;
top: 0;
left: 50%;
width: 150px;
margin-left: -75px;
}
JSFiddle: http://jsfiddle.net/bH35r/
P.S. I'm willing to utilize pretty much anything as long as it does the job cleanly.
You can use display:inline-block;
FIDDLE
HTML :
<div class="section header">
<div class="container no-border">
<a class="header" href="#">About</a>
<a class="header" href="#">News</a>
<a class="header" href="#">Teams</a>
<div class="logo_wrap">
<img id="logo" src="http://equineclub.zachschristmaslist.info/images/pennant.png"/>
</div>
<a class="header" href="#">Apparel</a>
<a class="header" href="#">Sponsorship</a>
<a class="header" href="#">Contact</a>
</div>
</div>
CSS :
body {
margin: 0;
font-family: Helvetica;
font-size: 100%;
background-color: #191A18;
}
.section {
margin: 0;
padding: 0;
clear: both;
}
.section.header {
background-image: url('../images/background.png');
background-position: 50% 90%;
border-bottom: 1px solid #A8A8A8;
box-shadow: 0 1rem 1rem #000;
text-align: center;
}
.container {
max-width: 60rem;
margin: 0 auto;
padding: 0 1.5rem;
border-right: 1px solid black;
border-left: 1px solid black;
background-color: white;
}
.container.no-border {
border: none;
background-color: transparent;
position: relative;
}
.container.logo {
background-image: url('../images/main-image.jpg');
background-position: 50% 20%;
min-height: 20rem;
}
a.header {
color: white;
display:inline-block;
text-decoration: none;
padding: 3rem 1.5rem;
margin: 0 0.5rem;
background-color: rgba(255,255,255,0.1);
}
#logo {
width: 150px;
}
.logo_wrap{
display: inline-block;
height: 5.5rem;
vertical-align:top;
overflow:visible;
}
Use a CSS background image.
.container {
max-width: 60rem;
margin: 0 auto;
padding: 3rem 1.5rem;
border-right: 1px solid black;
border-left: 1px solid black;
background-color: white;
background-image:url(....);
background-repeat-no-repeat;
background-position: 0px 0px; <--- adjust accordingly.
}
In general, images that are part of the UI (not the content) should be CSS backgrounds, not inline images anyway.
With this CSS and HTML I get a gap above the <span>-tag and I don't know why this is happening:
CSS
<style>
header > aside {
float: left;
font-size: 0;
line-height: 0;
white-space: nowrap;
border: 1px solid green;
}
header > aside > span {
display: inline-block;
height: 19px;
margin: 0px 10px 0px 0px;
padding: 5px 0px 0px 0px;
opacity: 0.75;
font-size: 9px;
line-height: 9px;
text-transform: uppercase;
color: #0fa1b4;
border: 1px solid red;
}
a.share {
display: inline-block;
width: 24px;
height: 24px;
margin: -1px 0px 0px -1px;
padding: 0;
opacity: 0.45;
background: blue;
font-size: 0;
line-height: 0;
}
</style>
HTML
<header>
<aside>
<span>Follow</span>
<a class="share facebook" href=""></a>
<a class="share soundcloud" href=""></a>
</aside>
</header>
In action
http://jsfiddle.net/insertusernamehere/ZAVJJ/
I could solve it using float, but somehow I want to solve it without. I guess it's pretty simple, and I'm only overlooking something. But with just a few hours sleep, I can't figure it out. :)
vertical-align: top; on the span does the trick. See: http://jsfiddle.net/ZAVJJ/3/