Using the following markup, I'm creating an image with two floated text overlays, one for the heading and one for the summary text. It's rendering how I wish and I'm able to use the entire image as well as the headline & summary to access the link except for the area immediately to the right of the 'headline' up to the end of the 'summary'. This happens in all browsers (except IE9 and lower). Any ideas why and how I can get around it?
HTML:
<div class="image">
<img src="Assets/Images/Picture.jpg" alt="Picture" />
<div class="overlay">
Headline
Summo eirmod appareat ex mel. Vim odio error labores ex. Mea alii abhorreant et. Ad has nominati constituam. Sit falli nominati suavitate in.
</div>
</div>
CSS:
body {
border: 0;
color: #5B6064;
font-family: Helvetica, Arial, Sans-Serif;
font-size: .75em;
line-height: 1.6em;
margin: 0;
padding: 0;
background-color: #a5a5a5;
}
a {
text-decoration: none;
color: #5B6064;
}
a:visited {
text-decoration: none;
}
img {
border: 0;
}
.image {
position: relative;
width: 100%;
/* For IE6 */
display: block;
overflow: hidden;
}
.overlay {
position: absolute;
bottom: 10px;
left: 0;
display: block;
}
.headline {
color: #FFF;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: #e87b10;
/* Fallback for older browsers */
background: rgba(232,123,16,0.8);
padding: 10px;
float: left;
clear: left;
}
.summary {
max-width: 350px;
margin-top: 3px;
color: #FFF;
font: 14px/14px Helvetica, Sans-Serif;
letter-spacing: 0;
background: #e87b10;
/* Fallback for older browsers */
background: rgba(232,123,16,0.8);
padding: 10px;
float: left;
clear: left;
}
.summary a {
color: #FFF;
}
I'd wrap the whole thing in an a tag (cleaner code). You would need to adjust a bit of your css.
EDIT
I changed the div elements to span so it is syntactically correct (thanks for the reminder Phrogz). Since your css already had display: block for the div elements, changing them to span is not an issue.
<a href="Default.aspx">
<span class="image">
<img src="Assets/Images/Picture.jpg" alt="Picture" />
<span class="overlay">
<span class="headline">Headline</span>
<span class="summary">Summo eirmod appareat ex mel. Vim odio error labores ex. Mea alii abhorreant et. Ad has nominati constituam. Sit falli nominati suavitate in.</span>
</span>
</span>
</a>
The headline is being floated left. If you remove the float and add display:block; to the anchor, it will take up the full image width.
Related
I have tried with plugin its woking fine.
i need without plugin add some tooltip with css.
<div class="tooltip-text">Parent text
<span class="tooltiptext">Tooltip text here!</span>
</div>
styles:
.tooltip-box {
position: relative;
display: inline-block;
}
.tooltip-box .tooltip-text {
visibility: hidden;
width: 100px;
background-color: black;
color: #fff;
text-align: center;
padding: 6px 0;
position: absolute;
z-index: 1;
}
.tooltip-box:hover .tooltip-text {
visibility: visible;
}
if using some text contents it works fine.
now i m using buttons here
<div class="kt-btn-wrap kt-btn-wrap-2">
<a class="kt-button button kt-btn-2-action kt-btn-size-custom kt-btn-style-basic kt-
btn-svg-show-always kt-btn-has-text-true kt-btn-has-svg-false" >
<span class="kt-btn-inner-text">Tooltip Button</span>
</a></div></div>
if i use span class also didnt work. usual button style also changed. better solution suggest me Thank you
check this for button and text
.tooltip-text {
color:#000;
text-align: center;
padding: 6px 0;
position: absolute;
z-index: 1;
}
.tooltip-text .tooltiptext, .kt-btn-wrap .tooltiptext{visibility:hidden;}
.tooltip-text:hover .tooltiptext,
.kt-btn-wrap:hover span.tooltiptext{
visibility: visible;background-color: black;color:#fff;width:100%;
}
<div class="tooltip-text">Parent text
<span class="tooltiptext">Tooltip text here!</span>
</div><br><br>
<div class="kt-btn-wrap kt-btn-wrap-2">
<a class="kt-button button kt-btn-2-action kt-btn-size-custom kt-btn-style-basic kt-
btn-svg-show-always kt-btn-has-text-true kt-btn-has-svg-false" >
<span class="kt-btn-inner-text">Tooltip Button</span>
</a><span class="tooltiptext">Tooltip text here for button!</span></div>
Your actual code should work (granted you're fixing class names – your example code has some "deviations" ...).
Example 1
.kt-button {
position: relative;
display: inline-block;
}
.kt-btn-inline {
border: none;
appearance: none;
background-color: transparent;
padding: 0;
font-family: inherit;
font-size: inherit;
}
.kt-btn-inner-text,
.kt-btn-inner {
visibility: hidden;
width: 100px;
color: #fff;
text-align: center;
padding: 6px 0;
position: absolute;
z-index: 1;
}
.kt-btn-inner-text {
background-color: black;
color: #fff;
}
.kt-button:hover .kt-btn-inner {
visibility: visible;
}
<p>
<a class="kt-button button kt-btn-2-action kt-btn-size-custom kt-btn-style-basic kt-
btn-svg-show-always kt-btn-has-text-true kt-btn-has-svg-false">
Button Text (Link)
<span class="kt-btn-inner kt-btn-inner-text">Tooltip text</span>
</a>
</p>
<p>
<button class="kt-button kt-btn-inline button kt-btn-2-action kt-btn-size-custom kt-btn-style-basic kt-
btn-svg-show-always kt-btn-has-text-true kt-btn-has-svg-false">
Button Text (Button)
<span class="kt-btn-inner kt-btn-inner-text">Tooltip text</span>
</button>
</p>
<p>
<button class="kt-button kt-btn-inline button kt-btn-2-action kt-btn-size-custom kt-btn-style-basic kt-
btn-svg-show-always kt-btn-has-text-true kt-btn-has-svg-false">
Button image tooltip
<span class="kt-btn-inner"><img width="200" height="300" src="http://placekitten.com/g/200/300"></span>
</button>
</p>
So most likely there are some typos in your html or css.
The main concept is perfectly OK:
tooltip parent element has position:relative
tooltip text gets position: absolute and hidden visibility that's toggled on hover
Example 2: inlined tooltips
* {
box-sizing: border-box;
}
body {
font-family: "Segoe UI", sans-serif;
}
:root {
--border-radius: 0.3em;
--bg-color: rgba(0, 0, 0, 0.7);
--padding: 0.3em;
}
button {
appearance: none;
border: 1px solid #ccc;
padding: 0.3em;
font-size: 2em;
}
.layout {
width: 50%;
margin: 0 auto;
}
.tooltip {
position: relative;
}
span.tooltip {
font-weight: bold;
}
.tooltip-content:before {
content: "";
display: inline-block;
position: absolute;
border: var(--padding) solid transparent;
border-bottom-color: var(--bg-color);
top: calc((var(--padding) * 2 * -1));
left: 50%;
margin-left: calc(var(--padding) / 2 * -1);
border-radius: 0;
}
.tooltip-content {
position: absolute;
top: calc(100% - (var(--padding) * 2));
left: 50%;
z-index: 1;
visibility: hidden;
opacity: 0;
margin-top: calc(var(--padding) * 3);
transform: translateX(-50%);
display: block;
background-color: var(--bg-color);
width: calc(100% + var(--padding));
width: 100%;
min-width: 8em;
color: #fff;
text-align: center;
padding: var(--padding);
padding-top: calc(var(--padding) / 2);
border-radius: var(--border-radius);
transition: 0.3s;
font-size: 1rem;
line-height: 1.2rem;
vertical-align: baseline;
font-weight: normal;
}
.tooltip:hover .tooltip-content {
visibility: visible;
opacity: 1;
}
.tooltip-content-img {
padding: 0!important;
}
<div class="layout">
<button class="tooltip">Test button
<span class="tooltip-content">Tooltip text here!</span>
</button>
<p>Lorem ipsum dolor sit amet, <span class="tooltip">consectetuer adipiscing <span class="tooltip-content">Tooltip text here!</span></span> elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, <span class="tooltip">image <span class="tooltip-content tooltip-content-img"><img src="http://placekitten.com/g/200/300"></span></span> pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate</p>
</div>
Should work for any parent element. But you might have more specific css rules inherited by your theme or plugins (... uhm, wordpress). So you will need to inspect your computed styles in dev tools if you encounter any issues.
How can i match the height of the h1 with the p tag?
I want to set the h1 to the left followed by the p on the same base line
.row_cont {
float: left;
width: 33.33333333%;
overflow: hidden;
border-left: 0.5px solid rgba(0, 0, 0, 0.37);
padding-right: 15px;
padding-left: 15px;
}
.row_cont h1 {
font-size: 70px;
float: left;
margin-right: 10px;
}
.row_cont p {
font-size: 12px;
margin: 0;
padding: 0;
overflow: hidden;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="page_container">
<div class="row">
<div class="col-md-12">
<div class="row_cont">
<h1>1</h1>
<p>Lorem ipsum dolor sit amet</p>
</div>
<div class="row_cont">
<h1>2</h1>
<p>Aenean massa. Cum sociis natoque penatibus </p>
</div>
<div class="row_cont">
<h1>3</h1>
<p>Cras dapibus. Vivamus elementum semper nisi. </p>
</div>
</div>
</div>
</div>
I've tried vertical-align but it's not working, here is my fiddle
you could use the sibling css selectors...
h1, h1 + p {
line-height: 1.5;
font-size: 2rem;
font-weight: bold;
display: inline;
}
<h1>Title</h1><p>Paragraph</p>
EDIT:
this will only be possible by trial and error with the vaules, since the line (and the highest characters in a font) extends above the top of the digits you are using in H1. Basically, use display: inline-block; and vertical-align: top on both containers, then adjust the margin-top settings of both:
.h1_cont, .p_cont {
display: inline-block;
vertical-align: top;
}
.h1_cont h1 {
margin-top: 0;
}
.p_cont p {
margin-top: 5px;
}
https://fiddle.jshell.net/rk7nap5u/3/
I have the fa-circle-thin in which i want to place a glyphicon, so that it looks like there is a round border around my glyphicon. I just want to know if this is even possible?
I've tried following:
<div class="col-md-4">
<span class="circle">
<i class="glyphicon glyphicon-star"></i>
</span>
<h4 class="service-heading">Lorem</h4>
<p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima maxime quam architecto quo inventore harum ex magni, dicta impedit.</p>
</div>
However the two icons shows up side by side. I made a class for my FA that looks like this:
.circle:before {
font-family: fontawesome-webfont;
text-decoration: none;
content: "\f1db";
background-color: transparent;
z-index:-1;
}
I'd just use border-radius: 50% instead of trying to position two glyphs (plus you can style the border!). I'm also centering things with text-align: center and by matching the line-height and height values:
.circle {
border: 1px solid black;
border-radius: 50%;
padding: 3px;
width: 25px;
height: 25px;
display: inline-block;
text-align: center;
line-height: 25px;
}
.alt {
border-width: 2px;
border-color: red;
color: red;
width: 15px;
height: 15px;
line-height: 15px;
}
<div class="circle">
🌟
</div>
<div class="circle alt">
🌟
</div>
How about using posiiton:absolute?
.glyphicon{
position: absolute;
top: 3px;
left: 15px;
}
Result: jsfiddle
I have a block of code that is solid. Works fine. Except for the footer of my site. No idea why but the heading bars are not showing for the footer but they are everywhere else?
here is a pen of the working code
http://codepen.io/VincentStephens/pen/EjyJKP
Here is a screenshot of the not working site:
https://www.dropbox.com/s/y3oxrvzvdvyaai6/Screen%20Shot%202015-05-19%20at%2019.07.47.png?dl=0
This works by creating a :before element. Putting the menu text into a span, then using z-index to position the span on top of the :before.
You can see the element there (see photo), everything is the same but just won't show unless I change the z-index to 0 or higher but then the line is above the heading text in the span???
h1.heading {
color: $light-gold;
text-transform: uppercase;
font-size: 32px;
font-weight: 300;
line-height: 40px;
font-family: SourceSansPro;
span {
background-color: $golden-black;
display: inline-block;
z-index: 1;
padding-right: 10px;
}
}
h1.heading:before {
content: "";
background-color: $light-gold;
display: block;
position: relative;
top: 23px;
width: 100%;
height: 6px;
z-index: -1;
}
HTML - working
<h1 class="heading"><span>The Team</span></h1>
HTML - Footer, not working
<div class="fluid-container footer">
<footer class="container">
<div class="col-lg-4">
<h1 class="heading"><span>About</span></h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quasi vero, inquit, perpetua oratio rhetorum solum, non etiam philosophorum sit. Quae sunt igitur communia vobis cum antiquis, iis sic utamur quasi concessis; De illis, cum volemus. Duo Reges: constructio interrete. Huic mori optimum esse propter desperationem sapientiae, illi propter spem vivere.</p>
</div>
<div class="col-lg-4">
<h1 class="heading"><span>Address</span></h1>
<p class="address">
address<br>
</p>
<p class="address">
Tell: 0207 374 6141 <br>
Email: enquiries#company.com
</p>
</div>
<div class="col-lg-4">
<h1 class="heading"><span>Connect</span></h1>
<img src="img/social-media.png" width="186" height="46">
<h1>Payment Options</h1>
<img src="img/payment-cards.png" width="267" height="56">
</div>
</footer>
</div>
Thanks for the moment on sanity.... it was indeed a position issue.
The footer also has a background colour. so that entire element needed to have a position: relative; and z-index: -1; added to it.
full code for anyone else in same situation:
SCSS - wil need compiling
.fluid-container.footer {
position: relative;
z-index: -1;
background-color: $light-golden-black;
footer {
h1.heading {
color: $light-gold;
text-transform: uppercase;
font-size: 32px;
font-weight: 300;
line-height: 40px;
font-family: SourceSansPro;
position: relative;
span {
background-color: $light-golden-black;
display: inline-block;
z-index: 1;
padding-right: 10px;
position: relative;
}
}
h1.heading:before {
content: "";
background-color: $light-gold;
display: block;
position: absolute;
top: 23px;
width: 100%;
height: 6px;
z-index: -1;
}
}
}
The best way I could describe what I want is with this picture:
How do I make it so the text aligns with the top text, and not the radio button?
Relevant CSS is as follows:
.basic-grey {
width: 600px;
margin-right: auto;
margin-left: auto;
background: #FFF;
word-wrap: break-word;
padding: 20px 30px 20px 30px;
font: 12px "Myriad Pro", sans-serif;
color: #888;
text-shadow: 1px 1px 1px #FFF;
border:1px solid #DADADA;
}
}
.basic-grey h1>span {
display: block;
font-size: 11px;
}
.basic-grey label {
display: block;
margin: 0px 0px 5px;
}
.basic-grey label>span {
float: left;
width: 80px;
text-align: right;
padding-right: 10px;
margin-top: 10px;
color: #888;
}
.basic-grey select {
background: #FFF url('down-arrow.png') no-repeat right;
background: #FFF url('down-arrow.png') no-repeat right);
appearance:none;
-webkit-appearance:none;
-moz-appearance: none;
text-indent: 0.01px;
text-overflow: '';
width: 72%;
height: 30px;
}
.basic-grey textarea{
height:100px;
}
.basic-grey p {
display: inline ;
}
;}
Markup:
<form name="frm1" action="index4.php" method="POST" class="basic-grey">
<h3>2. I have taught the course, several times face to face, that I wish to transform into a blended format. </h3>
<input type="radio" name="q2" value="1" /> <p>This statement accurately reflects my experience.</p><br>
<input type="radio" name="q2" value="2" /> <p>This statement partially reflects my experience (I have taught the course only a few times or once before).</p><br>
<input type="radio" name="q2" value="3" /> <p>This statement does not reflect my experience (this a new course that I will teach for the first time in a blended format).</p><br>
<br>
<input type="submit" name="button" class="button" value="Submit" />
</form>
When I try to float the radio button, all the text becomes out of whack.
It's pretty simple, just turn your label element to display: block; and use margin-left for the label and float your radio button to the left
Demo
Demo 2 (Nothing fancy, just used multiple radio for the demonstration)
input[type=radio] {
float: left;
}
label {
margin-left: 30px;
display: block;
}
Just note that say if you are storing the radio with the labels in an li element, something like
<ul class="radiolist">
<li>
<input type="radio"><label>Your text goes here</label>
</li>
</ul>
So make sure you self clear them by using something like
.radiolist li:after {
content: "";
clear: both;
display: table;
}
That will ensure that you are self clearing all the li elements, and about the :after psuedo, it is well supported in IE8 so nothing to worry about.
Flexbox solution:
Now that flexbox is widely supported, a simple display: flex; will work like magic.
Just wrap both the input and text with a <label> (so that clicking the text also toggles the input without the need for a for=""), and voila!
.flex-label {
display: flex;
}
input[type=radio] {
/* one way to help with spacing */
margin-right: 12px;
}
<label class="flex-label">
<input type="radio">
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </span>
</label>
If you want to keep the <label> separate, just wrap both in an element for applying the flex fix: https://jsfiddle.net/pn4qyam5/
This worked for me
input[type=radio] {
float: left;
display: block;
margin-top: 4px;
}
label {
margin-left: 15px;
display: block;
}
.basic-grey {
word-wrap: break-word;
font: 12px "Myriad Pro",sans-serif;
color: #888;
text-shadow: 1px 1px 1px #FFF;
}
.basic-grey p {
padding-left:20px;
}
.basic-grey input[type=radio] {
margin-left:-15px;
}
Assuming that your markup is:
<p><input type="radio"/>This statements actually...</p>
I love this:
HTML:
<input type="radio" name="vacation" value="Ski Trips"><label>very long label ...</label>
CSS:
input[type="radio"] {
position: absolute;
}
input[type="radio"] ~ label {
padding-left:1.4em;
display:inline-block;
}