Made a web portfolio. Around my name there is contact data. Initial width of text is 0, when hovering the icons expand with the "transition" property. Icons on the left work fine, but those on the right have a weird transition, especially the phone.
http://jsfiddle.net/4y9eW/
<div class="contactbox left">
<a href="https://twitter.com/D4NiMG" class="contactchild" id="contacttwittertext">
<span class="contacticon-twitter"></span>
<span class="contacttext">#D4NiMG</span>
</a>
<a href="https://plus.google.com/+DaniMu%C3%B1ozGuardiola" class="contactchild" id="contactgoogleplustext">
<span class="contacticon-google-plus"></span>
<span class="contacttext">+DaniMuñozGuardiola</span>
</a>
</div>
<span id="titlespan">Dani Guardiola</span>
<div class="contactbox right">
<a href="mailto:d4nimg#gmail.com" class="contactchild" id="contactemailtext">
<span class="contacticon-email"></span>
<span class="contacttext">d4nimg#gmail.com</span>
</a>
<a href="tel:+34607017025" class="contactchild" id="contactphonetext">
<span class="contacticon-phone"></span>
<span class="contacttext">+34 607 01 70 25</span>
</a>
</div>
CSS:
.contacttext {
display: none;
white-space: nowrap;
}
.contactchild:hover .contacttext {
display: inline-block;
}
.contactchild {
position: relative;
display: inline-block;
overflow: hidden;
width: 32px;
color: white;
transition: width 0.3s;
}
#contacttwittertext:hover {
transition: width 0.3s;
width: 107px;
color: #00aced;
}
#contactgoogleplustext:hover {
transition: width 0.3s;
width: 189px;
color: #D34836;
}
#contactemailtext:hover {
transition: width 0.3s;
width: 175px;
color: #8036d3;
}
#contactphonetext:hover {
transition: width 0.3s;
width: 154px;
color: #6fd336;
}
The problem with the phone is that the text wraps. Set
.contactchild { white-space: nowrap }
The weird overlap is caused by your misuse of position: absolute. Get rid of that. Move it around with margins, the parent forcing nowrap.
The weird underscores has to do with the spaces in the HTML. See 1 vs 2. It's <a>'s underline (note the spaces).
Related
I'm struggling with getting a section background color to change on mouse over. I'm trying to turn the entire section into a link. Right now, only the elements inside the section become links, not the block itself.
If I remove the <section> prior to the <a> the whole block becomes a link but the background sill does not change on mouse-over. I have an identical scenario in a menu and it works, so I'm a little confused here. I'm also wondering why only the elements turn into links withing a section and it does the opposite in my sub menu. Section code below:
.ch-section {
position: relative;
min-height: 140px;
max-height: 140px;
width: 400px;
color: $ch-section-text;
font-size: 13px;
border-bottom: 1px solid $body-1px-line;
}
.ch-section a {
display: block;
width: 400px;
text-decoration: none;
}
.ch-section a.active {
font-weight: bold;
}
.ch-section a:hover:not(.active) {
background-color: yellow;
color: $sn-list-link-active;
}
<section class="ch-section">
<a href="#">
<span class="ch-section-selected not"></span>
<img class="ch-section-image" src="assets/images/profileimg2.png" alt="img">
<span class="ch-section-user">
<span class="ch-section-status online"></span>
<span class="ch-section-name">Lindset T. Peters</span>
<span class="ch-section-location">Location, Province</span>
</span>
<time class="ch-section-date">8:48 AM</time>
<i class="fa fa-e1-message-sent ch-section-message"></i>
<span class="ch-section-snippet">Hey, it was really good to see you over the weekend, I look forward to...</span>
</a>
</section>
I'm struggling with getting a section background color to change on
mouse over. I'm trying to turn the entire section into a link. Right
now, only the elements inside the section become links, not the block
itself.
If I remove the prior to the the whole block becomes a
link but the background sill does not change on mouse-over.
It is because you have a as child of the section, so make it parent (as I did it in a previous question you had).
.ch-section {
position: relative;
min-height: 140px;
max-height: 140px;
width: 400px;
color: $ch-section-text;
font-size: 13px;
border-bottom: 1px solid $body-1px-line;
}
a {
text-decoration: none;
}
a .ch-section {
display: block;
width: 400px;
}
a.active .ch-section {
font-weight: bold;
}
a:hover:not(.active) .ch-section {
background-color: yellow;
color: $sn-list-link-active;
}
<a href="#">
<section class="ch-section">
<span class="ch-section-selected not"></span>
<img class="ch-section-image" src="assets/images/profileimg2.png" alt="img">
<span class="ch-section-user">
<span class="ch-section-status online"></span>
<span class="ch-section-name">Lindset T. Peters</span>
<span class="ch-section-location">Location, Province</span>
</span>
<time class="ch-section-date">8:48 AM</time>
<i class="fa fa-e1-message-sent ch-section-message"></i>
<span class="ch-section-snippet">Hey, it was really good to see you over the weekend, I look forward to...</span>
</section>
</a>
The actual problem here is that you haven't set the height of your a tag. However when setting the a tag height to 100%, you will notice it still won't work. This is because the section has no fixed height specified. Instead you specified both min-height and max-height to be the same height, which doesn't really make sense. If instead you specify height:140px, it will work as expected:
.ch-section {
position: relative;
height: 140px;
width: 400px;
font-size: 13px;
}
.ch-section a {
display: block;
height: 100%;
text-decoration: none;
}
.ch-section a.active {
font-weight: bold;
}
.ch-section a:hover:not(.active) {
background-color: yellow;
}
<section class="ch-section">
<a href="#">
<span class="ch-section-selected not"></span>
<img class="ch-section-image" src="assets/images/profileimg2.png" alt="img">
<span class="ch-section-user">
<span class="ch-section-status online"></span>
<span class="ch-section-name">Lindset T. Peters</span>
<span class="ch-section-location">Location, Province</span>
</span>
<time class="ch-section-date">8:48 AM</time>
<i class="fa fa-e1-message-sent ch-section-message"></i>
<span class="ch-section-snippet">Hey, it was really good to see you over the weekend, I look forward to...</span>
</a>
</section>
I need to show an edit icon next to the text (inline), when user hovers mouse over it. When i hover over the text, the edit icon is falling in the next line.
My span is taking up the 100% of div width, even though i have set it to 80% width and the rest 20% width is reserved for the right side icon.
Span style is,
span{
display: inline-block;max-width:80%;width:80%;
}
It looks like,
How can i display the icon inline, at the right end in the same line as the text?
Plunker code is here.
You can do like this.
$('document').ready(function(){
console.log('document ready callback fn is invoked')
$('.menu-body').hide()
})
$('body').on('click', '.drp-down-btn', function(){
$('.menu-body').toggle()
})
.cntr{
width: 20%;
overflow: hidden;
white-space: nowrap;
display: block;
}
.cntr i {
visibility: hidden;
opacity: 0;
transition: all 0.4s;
-webkit-transition: all 0.4s;
cursor: pointer;
}
<!-- .cntr:hover{
border: solid black 1px;
} -->
.cntr:hover > i{
display: inline-block;
}
.cntr>span>p{
width: 15%;
overflow:hidden;
vertical-align:middle;
text-overflow: ellipsis;
white-space: nowrap;
}
.cntr span,.cntr p,.cntr i{
display: inline-block;
}
.cntr:hover i{
visibility: visible;
opacity: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<body>
<div class="cntr">
<span>
<p>Hello worldaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
<i class="fa fa-edit fa-lg" style="padding-left:5px;border-left: solid black 1px;">
</i>
</span>
</div>
<script src="script.js"></script>
</body>
span is inline element by default and you cannot add width to it unless you display it as block.
<div>
<span style="display:inline-block; width:80%;">Hello Hello Hello</span>
<i style="display:inline-block; padding-left:5px;float: right; border-left: solid black 1px; width: 15%;">ICON</i>
</div>
I'm currently creating a website which is created by three main divs on one page. In-between each div, I have a faint hr to help visually 'split them up'.
Between my first and second divs, the hr displays fine.
Between the second and third is my problem - the hr displays underneath the second div. I have a feeling it is to do with the relative positioning of the container of my second div, but that is needed for me to position images within in.
I have tried display:block and wrapping the second div inside another container amongst other things, but nothing has yet worked.
I could try using div with a background/border rather than hr, but i'm not sure if this is the right way to approach it (i'm still learning my way around things).
Below is my code for the 'second div' and the hr I am trying to position.
<!-- PORTFOLIO -->
<div id="portfoliocont">
<div class="smallthumb" id="thumb1">
<a href="media/pamabest/pamabesttitle-large.jpg" class="overlay" data-lightbox="image-1" data-title="Pamabest" class="show">
<a href="media/pamabest/app-login.jpg" class="overlay" data-lightbox="image-1" data-title="Log in with your own account">
<a href="media/pamabest/tutorial.jpg" class="overlay" data-lightbox="image-1" data-title="Message your friends">
<a href="media/pamabest/app-profile.jpg" class="overlay" data-lightbox="image-1" data-title="Create your own profile">
<a href="media/pamabest/app-messages.jpg" class="overlay" data-lightbox="image-1" data-title="Message your friends">
<a href="media/pamabest/karaoke--menu.jpg" class="overlay" data-lightbox="image-1" data-title="Have a laugh">
<a href="media/pamabest/lists-viewlist.jpg" class="overlay" data-lightbox="image-1" data-title="Be prepared">
<a href="media/pamabest/mycar.jpg" class="overlay" data-lightbox="image-1" data-title="See the stats">
<a href="media/pamabest/weather.jpg" class="overlay" data-lightbox="image-1" data-title="Pack wisely">
<a href="media/pamabest/ticket5pariswhitestarstextured.jpg" class="overlay" data-lightbox="image-1" data-title="Front of 'Pamabest: Paris' ticket">
<a href="media/pamabest/ticketbackwhitestarstextured.jpg" class="overlay" data-lightbox="image-1" data-title="Back of 'Pamabest: Paris' ticket">
<a href="media/pamabest/travelticket2withbannertextured.jpg" class="overlay" data-lightbox="image-1" data-title="Front of 'Pamabest: Travel Pass' ticket">
<a href="media/pamabest/travelticket2backtextured.jpg" class="overlay" data-lightbox="image-1" data-title="Front of 'Pamabest: Travel Pass' ticket">
<img src="images/smallthumb/pamabest-small.jpg" alt="Imaginary music festival, Pamabest"/ title="Pamabest companion app">
<h1>"Pamabest" is a European, multi-cultural music festival aimed at 18-30 year olds.<br>A companion app would be used to help festival goers navigate the park and enhance their overall experiance.</h1></a>
<p>Pamabest music festival</p>
</div>
<div class="smallthumb" id="thumb2">
<a href="media/pisforpsychohd.mov" class="overlay">
<img src="images/smallthumb/psycho-small.jpg" alt="2 Minute video recreating a scene from the move, P is for Psycho" title="P is for Psycho video"/>
<h1>Filmed within a group, the video is a recreation of the 'bathroom scene' from the movie. <br>All editing was made in Premier Pro.</h1></a>
<p>P is for Pscyho</p>
</div>
<div class="smallthumb" id="thumb3">
<a href="media/silverlake/build/index.html" class="overlay" target="_blank">
<img src="images/smallthumb/silverlake-small.jpg" alt="Silverlake Website" title="Silverlake theme park website"/>
<h1>Silverlake theme park is based in the heart of Yorkshire, boasting a zoo and other child-friendly features. <br> The website was made with HTML5 and CSS3, graphical assests were made in Photoshop and Illustrator.</h1></a>
<p>Silverlake themepark</p>
</div>
<div class="blankthumb" id="thumb4"></div>
<div class="blankthumb" id="thumb5"></div>
<div class="blankthumb" id="thumb6"></div>
</div>
<hr>
And my CSS
hr {
margin: 40px 0px;
border: none;
height: 1px;
color: #ececec; /* old IE */
background-color: #ececec; /* Modern Browsers */
}
/* PORTFOLIO
--------------------------*/
#portfoliocont {
position: relative;
margin-bottom: 40px;
display: block;
}
.smallthumb, .blankthumb {
display: inline-block;
position: absolute;
}
.smallthumb a {
text-decoration: none;
}
.smallthumb img {
-webkit-box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.23);
-moz-box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.23);
box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.23);
}
.blankthumb {
background: #f2f2f2;
width: 296px;
height: 174px;
}
#thumb1 {
left: 0px;
top: 0px;
}
#thumb2 {
left: 335px;
top: 0px;
}
#thumb3 {
right: 0px;
top: 0px;
}
#thumb4 {
left: 335px;
top: 250px;
}
#thumb5 {
right: 0px;
top: 250px;
}
#thumb6 {
left: 0px;
top: 250px;
}
#portfoliocont p {
padding-top: 10px;
color: #808080;
font-weight: 400;
}
.overlay h1 {
position: absolute;
/*display: inline-block;*/
height: 164px;
width: 276px;
bottom: 0;
top: 0;
color: white;
background-color: #806d9e;
opacity: 0;
font: 1em "Helvetica Neue";
text-align: left;
padding: 10px 10px 0px 10px;
line-height: 1.4em;
transition: transform 0.3s, opacity 0.3s;
-ms-transition: -ms-transform 0.3s, opacity 0.3s;
-webkit-transition: -webkit-transform 0.3s, opacity 0.3s;
}
.overlay h1 br{
display: block;
line-height: 2em;
}
.overlay:hover h1{
opacity: 1;
}
#thumb1 a.show {
display: block;
}
#thumb1 a {
display: hidden;
}
Thanks
Your problem here is all the thumbs with position: absolute;
When the browser renders an element with position: absolute; it doesn't take any space.
In your case, the #portfoliocont "has nothing inside".. What I mean is that anything inside that div occupies any space. Therefore, it's height is zero.
Following your zero-height div, the browser continues to render the <hr /> tag.
I strongly recommend not to position your thumbs absolutely. You have many other options, such as:
Display inline-block
Float left
Flexbox (watch out for browser support on this one)
Here is a simple example of using inline-block for the thumbs: https://jsfiddle.net/Lfhctqkg/
Defining div height, solved this little problem for me. An easier way, at least for a student on a simple task.
I'm using Bootstrap in order to create a notification-like drop down when the user mouseovers the bell icon (font-awesome). The menu is created alright, each element inside the menu is indicated by a red chevron sign. I'm not able to center the chevron vertically and align the text to the right of the chevron to start from the same place (there's some margin at the beginning of each line). I cant vertically center the chevron with a fixed value because the length of the string inside the container can be different and the position of the chevron should be determined dynamically.
Basically, I'm creating a jQuery element
$("<div class='notification-content'><i class='ion-chevron-right'></i><span class=''>"+randromString+"</span></div>");`,
and the chevron is inserted with the content.
JSfiddle here.
HTML
<div class="notifications_wrap text-center center b-l b-r hidden-sm hidden-xs">
<span class="vlign"> </span>
<a href="#" id="notification-center" aria-haspopup="true" data-toggle="dropdown">
<i class="glyphicon glyphicon-bell"></i>
<span class="bubble "></span>
</a>
<div class="dropdown-menu notification-toggle1" role="menu" aria-labelledby="notification-center" id="notif">
<!-- START Notification -->
<div class="notification-panel">
<div class="test"></div>
</div>
</div>
</div>
CSS
#notif{
background-color: white;
color: black;
}
.notification-content{
text-align: left;
padding: 10px;
padding-right: 25px;
border-bottom: 1px solid #ddd;
transition: 0.4s ease;
}
.notification-content:hover{
color: #48B0F7;
}
.notification-toggle1 {
top: 75px;
padding: 0;
z-index: 9999;
left: 100px;
width: 250px;
}
/* > sign of the notification*/
.notification-content >.ion-chevron-right:before {
color: red;
/* display:inline-block;*/
vertical-align: middle;
line-height: 50%;
width: 50px;
height: 20px;
}
.notification-content>span{
position: relative;
left: 15px;
}
JS
$(".notifications_wrap").find("a").mouseover(function(){
$(".notification-content").remove();
var random_i=randomNumOfNotifs();
for(var i=0;i<random_i;i++){
var randromString = stringGen(randomLength());
var notification = $("<div class='notification-content'><i class='ion-chevron-right'></i><span class=''>"+randromString+"</span></div>");
$("#notif").append(notification);
}
$("#notif").animate({height:"show"},500);
});
You can add the following css:
.notification-content >.ion-chevron-right {
display:table-cell;
vertical-align:middle;
}
.notification-content>span{
display:table-cell;
}
Here is a fiddle
So I have a few elements in an inline-block which display perfectly as they should in Firefox but for some reason in Safari and Chrome the positioning is all off
CSS:
#bb-tools {
float: right;
width: 100%;
text-align: right;
position: absolute;
z-index: -1;
}
.main-tools {
display: inline-block;
color: #000000;
font-size: 0.8em;
margin-top: 10px;
width: auto;
height: 30px;
}
.main-tools a img.icon-space { margin-right: 5px; }
.main-tools a {
color: #000000;
text-transform: uppercase;
text-decoration: none;
margin: 0 0 0 15px;
}
.main-tools a:hover {
color: #f4cdd4;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.search-box-responsive {
display: block;
float: left;
height: auto;
}
HTML:
<div id="bb-tools">
<div class="main-tools"> <a rel="nofollow" href="#"><span class="login">Log In</span></a> <span class="help">Help</span> <a class="basket" rel="nofollow" href="#"><img src="http://www.placehold.it/20x23" width="18" height="20" style="display:inline-block; border:0;" alt="" /> <span class="basket-contents"> <span class="basket-count"><sup> (100) </sup></span></span></a>
<div class="search-box-responsive">
<form class="search-responsive" role="search" method="get" action="#">
<fieldset>
<input id="headerSearch" name="q" type="text" placeholder="Search" />
<input id="headerSearch" value="" type="submit" />
</fieldset>
</form>
</div>
</div>
</div>
See the fiddle, if opened in Firefox, displays as it should:
DEMO
Can someone explain? Thanks for reading
It's happening as none of your anchors are floated so it is pushing the form down to the next line before it can get floated.
If you wrap your anchors in a div and then add float:right to that div, it should fix your problem
Example
Note sure what is causing the issue since i didn't get what you're trying to achieve with the css.
If you just want to fix the issue, you can place the .search-box-responsive before the links in DOM, if possible.
Demo (tested in safari and chrome)
sidenote: float has no effect on absolutely possible elements, as far as i know.
Add .search-box-responsive div right after #bb-tools div as in
http://jsfiddle.net/4tjJt/2/