first child, last child or neither? - css

I have 4 mouse over images that pop out a box with 3 cells showing a title, date and paragraph. I need the 1st and last drop downs to be moved inward on the page so as not to be clipped by the left and right sides. I have been round and round with first child last child without any luck. Is it possible to change position of the left and right without affecting the middle drop down positions? If so How? Thank you.
.simple {
position: relative;
font-family: arial, verdana, helvetica, sans-serif;
background: black url(images/subbar.jpg) repeat-x top left;
font-size: 12px;
z-index: 0;
text-align: center;
}
.simple ul {
list-style: none;padding: 0px;margin: 0px;
display: inline-block;
}
.simple ul li {
display: block;
position: relative;
float: left;border: 0px solid #000;
text-align: left;
}
.simple li ul {
display: none;
background-color: lightyellow;
border: 1px solid gray;
padding: 3px 5px 3px 5px;
z-index: 50;
position: absolute;
top: 72px;
left: -60px; /* left 5px, middle 2 -60px and right -90px (currently all at -60px) */
}
.simple ul li a {
/* display: block;background: #fff; */
padding: 5px 5px 5px 5px;
text-decoration: none;
color: #000;
}
.simple li:hover ul {
display: block; position: absolute; /* show or hide dropdown */
}
.simple li:hover a {
background: none;
}
#drop-nav li ul li {
border-top: 0px;
}
<div class="simple">
<ul id="drop-nav">
<li><img src="img/image1.jpg" width="150px" height="70px" border="0" />
<ul>
<li><a><img src="img/golddesign.jpg" width="300px" height="26px" border="0" /><br /><strong>Title 1</strong>
Date 1<br>Paragraph 1..</a><strong>Read More</strong></li>
</ul>
</li>
<li><img src="img/image2.jpg" width="150px" height="70px" border="0" />
<ul>
<li><a><img src="img/golddesign.jpg" width="300px" height="26px" border="0" /><br /><strong>Title 2</strong>
Date 2<br>Paragraph 2..</a><strong>Read More</strong></li>
</ul>
</li>
<li><img src="img/image3.jpg" width="150px" height="70px" border="0" />
<ul>
<li><a><img src="img/golddesign.jpg" width="300px" height="26px" border="0" /><br /><strong>Title 3</strong>
Date 3<br>Paragraph 3..</a><strong>Read More</strong></li>
</ul>
</li>
<li><img src="img/image4.jpg" width="150px" height="70px" border="0" />
<ul>
<li><a><img src="img/golddesign.jpg" width="300px" height="26px" border="0" /><br /><strong>Title 4</strong>
Date 4<br>Paragraph 4..</a><strong>Read More</strong></li>
</ul>
</li>
</ul>
</div>

You are looking for something like this?
.simple li:first-child ul {
left: 0px;
}
.simple li:last-child ul {
right: 0px;
left:initial;
}

Add the below code in your css it will work:
In class simple additionally add the width,
ul#drop-nav li:first-child ul{margin-left: 65px;}
ul#drop-nav li:last-child ul{margin-left: -101px;}
for reference check this fiddle:
http://jsfiddle.net/o17ogsa8/

Related

How can i prevent the logo from moving when i edit the text?

I'm building a menu with two sections and a logo between.
And i would like to know how can I prevent the logo from moving whenIi change the text from both sections. I would like to fix the logo, when i change the about us for exemple, i would like to see the about us editing and moving to the left side, not to the right side.
Sorry for my english:
Jsfiddle:
http://jsfiddle.net/uL52rvwn/
HTML:
<div class="menu">
<div class="m-info">
<ul>
<li class="l-aboutus"><a>About us</a></li>
</ul>
</div>
<div id="logo"><img alt="logo" src="http://i.imgur.com/bebZYcu.png" width="80" height="80" /></div>
<div class="m-contact">
<ul>
<li class="l-ourcontacts"><a>Contacts</a></li>
</ul>
</div>
</div>
What I did? I made the m-info float:left, and m-contact float:right, than made the #logo's margins negative to move it to the center.
Fiddle: http://jsfiddle.net/uL52rvwn/3/
<style>
.m-info {
width: 50%;
float: left;
text-align: right;
margin-left: -40px;
padding-right: 40px;
}
.m-contact {
width: 50%;
float: right;
text-align: left;
padding-left: 40px;
margin-right: -40px;
}
#logo {
float: left;
margin-left: -40px;
margin-right: -40px;
}
.menu ul {
padding: 0;
}
.menu li {
display: inline;
padding: 10px;
color: #eaeaea;
text-transform: uppercase;
z-index: 11;
position: relative;
}
.m-info ul li a, .m-contact ul li a {
text-transform: uppercase;
color: #a1a1a1;
letter-spacing: 7px;
font-size: 12px;
}
.m-info ul li a:hover, .m-contact ul li a:hover{
cursor:pointer;
color:#c8c8c8;
}
.m-contact ul{
margin-right:20px;
}
</style>
<div class="menu">
<div class="m-info">
<ul>
<li class="l-aboutus"><a>About us</a></li>
</ul>
</div>
<div id="logo"><img alt="logo" src="http://i.imgur.com/bebZYcu.png" width="80" height="80" /></div>
<div class="m-contact">
<ul>
<li class="l-ourcontacts"><a>Contacts</a></li>
</ul>
</div>
</div>
Absolute positioning should work: http://jsfiddle.net/6L35a0up/7/
I changed the following CSS rule:
#logo img {
left:50%;
z-index: 12;
position: absolute;
}
And moved the logo div to outside of the .menu wrapper.

How do I keep nested children (li) inline for my footer navigation?

I have a simple question. I'm trying to display the elements for "about" "general" and "social-buttons" classes within a nested unordered list. I want these to appear horizontal and inline with each other. I want them to be side by side basically, not vertical. If you can help me figure out which selector I need to add the 'display:inline' block, that would be much useful.
<div class="footer-container">
<div id="footer_menu">
<div id="footer-copy">
<li class="about-blurb">
<h3>Viral DNA</h3>
<ul>
<li>
<p>Virael Marketing is the leading digital marketing blog for the social web. We are a one-stop hub to help you learn from your viral marketing campaigns, offer tips & tricks, and build the best digital marketing teams.</p>
</li>
</ul>
<li class="General">
<h3>General</h3>
<ul>
<li><a class="button" href="#">Media</a></li>
<li><a class="button" href="#">Resources</a></li>
<li><a class="button" href="#">Blog</a></li>
<li><a class="button" href="#">Store</a></li>
<li><a class="button" href="#">Contact</a></li>
</ul>
<li class="social-icons">
<h3>Follow Virael</h3>
<ul>
<li>
<!--social media buttons go here-->
</li>
</ul>
</ul>
</div>
</div>
The CSS:
.footer-container {
font-family: MyriadPro-Regular, 'Myriad Pro Regular', MyriadPro,'MyriadPro', Arial, sans-serif;
float: left;
text-align: left;
width: 828px;
text-transform: capitalize;
background-color: #4169E1;
color: #FFF;
position: relative;
bottom: 0;
left: 269px;
border-top: 10px solid #B0C4DE;
overflow: hidden;
z-index=-1000;
}
.footer-container h3 {
text-align:justify;
}
#footer_menu {
font-family: MyriadPro-Regular, 'Myriad Pro Regular', MyriadPro,'MyriadPro', Arial, sans-serif;
list-style-type:none;
z-index=-1000;
}
#footer_menu ul {
margin: 0px 30px;
padding: 10px 30px;
list-style-type:none;
text-decoration:none;
display:inline;
z-index=-1000;
}
#footer_menu ul li {
margin: 0 0;
padding: 5px 0;
z-index=-100;
display:block;
color: white;
clear:both;
}
#footer_menu .about-blurb ul li {
width: 200px;
height: auto;
text-align:justify;
}
Replace your css with mine. Live example here
#footer_menu ul {
/* margin: 0px 30px; */
padding: 10px 30px;
list-style-type: none;
text-decoration: none;
display: inline;
}
#footer_menu ul li {
margin: 0 0;
padding: 5px 0;
display: inline-block;
color: white;
clear: both;
}
Remove margins from the ul and add inline-block to li

divs move when hovering over other divs

I have a few work thumbnail divs in a container When I hover over one specific one, it shifts the ones after it along the next row. How can I resolve this?
HTML:
<div class="blog-container">
<h1>PRINT</h1>
<div class="work_thumbs">
<li class="print">
<div><img src="../Images/Tree Top News/Thumbs/TTN2.jpg" alt="Tree Top" border="0" class="thumb">TREE TOP NEWS</div>
</li>
<li class="print">
<div><img src="../Images/Harrow Council/Thumbs/Harrow Logo.jpg" alt="Harrow Council" border="0" class="thumb">HARROW COUNCIL</div>
</li>
<li class="print">
<div><img src="../Images/Regent/Thumbs/Regent logo.jpg" alt="Regent Care" border="0" class="thumb">REGENT CARE SERVICES</div>
</li>
<li class="print">
<div><img src="../Images/NLCS/Thumbs/NLCS logo.jpg" alt="NLCS" border="0" class="thumb">NLCS</div>
</li>
<li class="print">
<div><img src="../Images/Aish/Thumbs/AHC.jpg" alt="Aish" border="0" class="thumb"> AISH</div>
</li>
<li class="print">
<div><img src="../Images/FJL/Thumbs/FJL.jpg" alt="chicago graphic design" border="0" class="thumb">FJL</div>
</li>
<li class="print">
<div><img src="../Images/Tree Top News/Thumbs/TTN.png" alt="Canons high school" border="0" class="thumb">CANONS HIGH SCHOOL</div>
</li>
</div>
</div>
CSS:
.blog-container {
height: 100%;
width: 100%;
margin-top: 37px;
background-color:
}
.work_thumbs {
width:1000px;
margin: 0px auto 0 auto;
float: left;
}
.work_thumbs li {
margin: 0px 15px 15px 0px;
list-style-type: none;
display: block;
float: left;
display: inline;
font-family: "geogtq md";
color: #FFF;
overflow: hidden;
}
.work_thumbs li a {
float: inherit;
display: block;
width: 230px;
padding-bottom: 50px;
font-family: "geogtq md";
color: #00BDE5;
height: 200px;
border: 1px solid #02BDE5;
overflow: hidden;
}
.work_thumbs li .type {
color: #01BDE6;
}
.work_thumbs li a:hover {
background-color: #ceeef6;
border-bottom: 1px solid #a2a2a2;
text-decoration: none;
margin-bottom: -1px;
color: #007789;
font-family: "geogtq md";
}
.work_thumbs li .thumb {
margin-bottom: 15px;
display:block
}
element:hover{url('pathToImg.png'); position:relative; z-index:1;}
Make z-index:1 a higher index to suit your needs, and include a height and width as well.
You are changing the dimensions of your divs upon hover, by adding the negative margin-bottom. this causes your floating divs to 'hook' upon hover, in stead of starting at the left.
Here you can see it in action: http://jsfiddle.net/P8xEN/

Right align menu control inside a div tag

When a new web application project in ASP.NET created, it comes with a NavigationMenu in site.master page which has 2 elements (Home & About), Please let me know how to align this menu to the right.
Here it's screenshot & code:
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
IncludeStyleBlock="False" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="AnaSayfa"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="Hakkında" />
</Items>
</asp:Menu>
</div>
Here is the rendered html code:
<div style="float: left;" id="NavigationMenu" class="menu">
<ul style="width: auto; float: left; position: relative;" class="level1 static" role="menubar"
tabindex="0">
<li style="float: left; position: relative;" class="static" role="menuitem"><a class="level1 static"
tabindex="-1" href="Default.aspx">Ana Sayfa</a></li>
<li style="float: left; position: relative;" class="static" role="menuitem"><a class="level1 static"
tabindex="-1" href="About.aspx">Hakkında</a></li>
</ul>
</div>
Here CSS:
div.hideSkiplink
{
background-color:#3a4f63;
width:100%;
}
div.menu
{
padding: 4px 0px 4px 8px;
text-align: right;
}
div.menu ul
{
list-style: none;
margin: 0px;
padding: 0px;
width: auto;
}
div.menu ul li a, div.menu ul li a:visited
{
background-color: #465c71;
border: 1px #4e667d solid;
color: #dde4ec;
display: block;
line-height: 1.35em;
padding: 4px 20px;
text-decoration: none;
white-space: nowrap;
}
div.menu ul li a:hover
{
background-color: #bfcbd6;
color: #465c71;
text-decoration: none;
}
div.menu ul li a:active
{
background-color: #465c71;
color: #cfdbe6;
text-decoration: none;
}
Add text-align: right; to the div.menu style in Site.css.
Since something is adding a float:left; to the menu div, you need to override it in your CSS with float:right !important; as per Rajiv's suggestion. Make your CSS look like this:
div.menu
{
padding: 4px 0px 4px 8px;
text-align: right;
float: right !important;
}
The manual style being applied is probably due to some built-in menu styles. Check out the docs and the walk-throughs included there: http://msdn.microsoft.com/en-us/library/ecs0x9w5(v=vs.100) Especially the once related to ManuStyles and MenuItemStyles.
If you want to make text inside the div to right align go for following code
text-align:right;
But you if you want to move your whole div to right, you can go for
float:right
for information about "Float" property read this
How to align 3 divs (left/center/right) inside another div?

List doesn't display as grid with long texts

I'm having a problem sorting this out, basically it will be a list with icons and text below. Icon size remains the same but the text doesn't, as shown in the picture
.
The problem is when a <li> has a lot of text the rest float to the right of it. How can I sort this out.
My code is below:
ul.iconifier {
width: 100%;
list-style: none;
margin: 0 auto; padding: 0;
}
ul.iconifier li {
float: left;
margin: 10px; padding: 0;
text-align: center;
border: 1px solid #ccc;
width:8em;
height:200px;
-moz-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-khtml-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-webkit-border-radius: 3px; /*--CSS3 Rounded Corners--*/
display: block; /*--IE6 Fix--*/
height:101%;
}
ul.iconifier li a.thumb{
width: 128px;
height: 128px;
overflow: hidden;
display: block;
cursor: pointer;
}
ul.iconifier li a.thumb:hover {
}
ul.iconifier li p {
font: normal 0.75em Verdana, Arial, Helvetica, sans-serif;
margin: 0; padding: 10px 5px;
background: #f0f0f0;
border-top: 1px solid #fff; /*--Subtle bevel effect--*/
text-align:center;
width:118px;
}
ul.iconifier li a {text-decoration: none; color: #777; display: block;}
html:
<ul class="iconifier">
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>English Depatment</p>
</li>
<li>
<img src="img/sprite.png" alt="Art" />
<p>Art Deptartment</p>
</li>
<li>
<img src="img/sprite.png" alt="Travel and Tourism" />
<p>Mathematics</p>
</li>
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>Business Studies</p>
</li>
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>English Depatment with a really long title that will hopefully fall</p>
</li>
<li>
<img src="img/sprite.png" alt="Art" />
<p>Art Deptartment</p>
</li>
<li>
<img src="img/sprite.png" alt="Travel and Tourism" />
<p>Mathematics</p>
</li>
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>Business Studies</p>
</li>
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>English Depatment</p>
</li>
<li>
<img src="img/sprite.png" alt="Art" />
<p>Art Deptartment</p>
</li>
</ul>
You need to use display: inline-block; instead of float to get them to push the row below them down for modern browsers. For IE6 & IE7 use display: inline.
Replace your ul.iconifier li with this code:
ul.iconifier li
{
margin: 10px;
padding: 0;
text-align: center;
border: 1px solid #ccc;
width: 8em;
-moz-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-khtml-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-webkit-border-radius: 3px; /*--CSS3 Rounded Corners--*/
display: -moz-inline-box; /* mozilla only */
display: inline-block; /* for browsers that support display:inline-block*/
vertical-align: top;
}
Then add this code to make IE6 & IE7 work:
/* Show only to IE7 */
*:first-child + html ul.iconifier li
{
display: inline;
}
/* Show only to IE6 */
* html ul.iconifier li
{
display: inline;
}
I learn this approach from these sites:
http://gtwebdev.com/workshop/layout/inline-block-gallery.php
http://www.css-lab.com/demos/image-display/inline-block-caption.html
there is two ways the first one is using css by make a fix height for the small blocks with trimmed text to fixed length
the second solution is using the server side development code by adding a clear style to the first LI on the line (note: this solution is for a fix no. of blocks at line)
Not ideal, but you could make the elements all the same size, that way you'd never have a problem of things being floated to the right.
Try adding this to your CSS:
ul.iconifier li
{
margin-bottom: -5000px;
padding-bottom: 5000px;
}
That CSS should make the elements the same height.
Cheers, Sean
Perhaps you can use http://plugins.jquery.com/project/gridLayout

Resources