I have a list of businesses separated by categories. Next to each category name, starting at about 20px apart, I'd like to have a 3px tall border stretching to the end of the div. I would like for that border to be filled with a pattern, or image. Initially, I tried just using an image, but as each category name is a different length, that proved to be impractical.
I'm sure there is a relatively easy way to go about this, I'm just not certain on how to make it happen. Ideas?
Thanks.
updated image
here I'm using a <div> to show the border behind the <h1> category where both the <body> and <h1> have matching background patterns (that are also lined up)
example jsfiddle
CSS
body {
background:url('http://subtlepatterns.subtlepatterns.netdna-cdn.com/patterns/gray_jean.png');
font-family:helvetica,arial,sans-serif;
}
#container {
margin:0 20px;
position:relative;
}
h1 {
position:relative;
float:left;
padding-top:6px;
padding-right:20px;
font-size:2em;
background:url('http://subtlepatterns.subtlepatterns.netdna-cdn.com/patterns/gray_jean.png')
}
.border {
background:url('http://s3.amazonaws.com/creattica/uploaded-images/0016/6142/patterns_009_blue-hexagon-pattern_crop-iphone_web_for-creattica.jpg') repeat-x -10px 0;
position:absolute;
top:20px;
width:100%;
height:3px;
}
.listings {
clear:both;
}
HTML
<div id="container">
<div class="border"></div>
<h1>Catering</h1>
<div class="listings">
<ul>
<li>
Catering Company 1
</li>
<li>
...
</li>
</ul>
</div>
</div>
If additional markup is allowed (and your parent element has a solid background), you could go about it this way:
h1 {
background: red; /* replace with background-image */
}
h1 span {
background: white; /* replace with color of parent element's bg */
}
<h1><span>Test Headline</span></h1>
http://jsfiddle.net/358Gg/
Related
It will not format correctly, it won't remove the bullets nor will it format the block behind the text.
I'm out of ideas. Is there anyone that can coach me through this, please?
It will not format correctly, it won't remove the bullets nor will it format the block behind the text.
I'm out of ideas. Is there anyone that can coach me through this, please?
body {
margin:0;
padding:0;
border:0; /* This removes the border around the viewport in old versions of IE */
width:100%;
background:#fff;
min-width:600px; /* Minimum width of layout - remove line if not required */
/* The min-width property does not work in old versions of Internet Explorer */
font-size:90%;
}
a {
color:#369;
}
a:hover {
color:#fff;
background:#369;
text-decoration:none;
}
h1, h2, h3 {
margin:.8em 0 .2em 0;
padding:0;
clear:both;
}
p {
margin:.4em 0 .8em 0;
padding:0;
}
img {
margin:10px 0 5px;
}
#ads {
width:100%;
padding:20px 0;
}
#ads #mjt {
float:left;
margin-bottom:20px;
}
#ads .adhere {
margin:0 10px 10px 0;
}
#ads img {
display:block;
margin:0;
}
/* download link */
.download {
clear:both;
float:left;
padding-top:10px;
}
.download a {
padding:.3em .5em !important;
margin-right:10px;
background:#00bd3e;
text-decoration:none;
color:#fff;
font-weight:bold;
font-size:1.5em;
-moz-border-radius:.3em;
-webkit-border-radius:.3em;
border-radius:.3em;
line-height:2.5em;
-moz-box-shadow: 1px 1px 2px #888;
-webkit-box-shadow: 1px 1px 2px #888;
box-shadow: 1px 1px 2px #888;
}
.download a:hover {
background:#5f534f;
text-shadow: 2px 2px 2px #000;
}
/* Header styles */
#header {
clear:both;
float:left;
width:100%;
}
#header {
border-bottom:1px solid #000;
}
#header p,
#header h1,
#header h2 {
padding:.4em 15px 0 15px;
margin:0;
}
#header ul {
clear:left;
float:left;
width:100%;
list-style:none;
margin:10px 0 0 0;
padding:0;
}
#header ul li {
display:inline;
list-style:none;
margin:0;
padding:0;
}
#header ul li a {
display:block;
float:left;
margin:0 0 0 1px;
padding:3px 10px;
text-align:center;
background:#eee;
color:#000;
text-decoration:none;
position:relative;
left:15px;
line-height:1.3em;
}
#header ul li a:hover {
background:#369;
color:#fff;
}
#header ul li a.active,
#header ul li a.active:hover {
color:#fff;
background:#000;
font-weight:bold;
}
#header ul li a span {
display:block;
}
/* 'widths' sub menu */
#layoutdims {
clear:both;
background:#eee;
border-top:4px solid #000;
margin:0;
padding:6px 15px !important;
text-align:right;
}
**.navbar {
background-color: #333;
overflow: hidden;
}
.navbar li {
display: block;
margin-right: -4px;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
/* Style the links inside the navigation bar */
.navbar a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.navbar a:hover {
background-color: #ddd;
color: black;
}
/* Add a color to the active/current link */
.navbar a.active {
background-color: #4CAF50;
color: white;
}**
/* column container */
.colmask {
position:relative; /* This fixes the IE7 overflow hidden bug */
clear:both;
float:left;
width:100%; /* width of whole page */
overflow:hidden; /* This chops off any overhanging divs */
}
/* common column settings */
.colright,
.colmid,
.colleft {
float:left;
width:100%; /* width of page */
position:relative;
}
.col1,
.col2,
.col3 {
float:left;
position:relative;
padding:0 0 1em 0; /* no left and right padding on columns, we just make them narrower instead
only padding top and bottom is included here, make it whatever value you need */
overflow:hidden;
}
/* 3 Column settings */
.threecol {
background:#eee; /* right column background colour */
}
.threecol .colmid {
right:25%; /* width of the right column */
background:#fff; /* center column background colour */
}
.threecol .colleft {
right:50%; /* width of the middle column */
background:#f4f4f4; /* left column background colour */
}
.threecol .col1 {
width:46%; /* width of center column content (column width minus padding on either side) */
left:102%; /* 100% plus left padding of center column */
}
.threecol .col2 {
width:21%; /* Width of left column content (column width minus padding on either side) */
left:31%; /* width of (right column) plus (center column left and right padding) plus (left column left padding) */
}
.threecol .col3 {
width:21%; /* Width of right column content (column width minus padding on either side) */
left:85%; /* Please make note of the brackets here:
(100% - left column width) plus (center column left and right padding) plus (left column left and right padding) plus (right column left padding) */
}
/* Footer styles */
#footer {
clear:both;
float:left;
width:100%;
border-top:1px solid #000;
}
#footer p {
padding:10px;
margin:0;
}
<!DOCTYPE html PUBLIC
<head>
</head>
<body>
<div id="header">
<p>« Back to the CSS article by Matthew James Taylor</p>
<h1>The Perfect 3 Column Liquid Layout (Percentage widths)</h1>
<h2>No CSS hacks. SEO friendly. No Images. No JavaScript. Cross-browser & iPhone compatible.</h2>
</div>
<div class="navbar">
<ul>
<li>Column 1 <span>Holy Grail</span></li>
<li>3 Column <span>Column 2 </span></li>
<li>2 Column <span>Column 3 </span></li>
</ul>
</div>
<p id="layoutdims">Measure columns in: Pixel widths | Em widths | <strong>Percentage widths</strong></p>
</div>
<div class="colmask threecol">
<div class="colmid">
<div class="colleft">
<div class="col1">
<!-- Column 1 start -->
<p class="download">Download this layout (25kb zip file).</p>
<h2>Percentage dimensions of the holy grail layout</h2>
<img src="https://matthewjamestaylor.com/blog/perfect-3-column-dimensions.gif" width="350" height="370" alt="Three column layout dimensions" />
<p>All the dimensions are in percentage widths so the layout adjusts to any screen resolution. Vertical dimensions are not set so they stretch to the height of the content.</p>
<h3>Maximum column content widths</h3>
<p>To prevent wide content (like long URLs) from destroying the layout (long content can make the page scroll horizontally) the column content divs are set to overflow:hidden. This chops off any content that is wider than the div. Because of this, it's important to know the maximum widths allowable at common screen resolutions. For example, if you choose 800 x 600 pixels as your minimum compatible resolution what is the widest image that can be safely added to each column before it gets chopped off? Here are the figures:</p>
<dl>
<dt><strong>800 x 600</strong></dt>
<dd>Left & right columns: 162 pixels</dd>
<dd>Center page: 357 pixels</dd>
<dt><strong>1024 x 768</strong></dt>
<dd>Left & right columns: 210 pixels</dd>
<dd>Center page: 459 pixels</dd>
</dl>
<h2>The nested div structure</h2>
<p>I've colour coded each div so it's easy to see:</p>
<img src="https://matthewjamestaylor.com/blog/perfect-3-column-div-structure.gif" width="350" height="369" alt="Three column layout nested div structure" />
<p>The header, colmask and footer divs are 100% wide and stacked vertically one after the other. Colmid is inside colmask and colleft is inside colmid. The three column content divs (col1, col2 & col3) are inside colleft. Notice that the main content column (col1) comes before the other columns.</p>
<!-- Column 1 end -->
</div>
<div class="col2">
<!-- Column 2 start -->
<h2>No CSS hacks</h2>
<p>The CSS used for this layout is 100% valid and hack free. To overcome Internet Explorer's broken box model, no horizontal padding or margins are used in conjunction with a width. Instead, this design uses percentage widths and clever relative positioning.</p>
<h2>SEO friendly 2-1-3 column ordering</h2>
<p>The higher up content is in your page code, the more important it is considered by search engine algorithms. To make your website as optimised as possible, your main page content must come before the side columns. This layout does exactly that: The center page comes first, then the left column and finally the right column (see the nested div structure diagram for more info). The columns can also be configured to any other order if required.</p>
<h2>Full length column background colours</h2>
<p>In this layout the background colours of each column will always stretch to the length of the longest column. This feature was traditionally only available with table based layouts but now with a little CSS trickery we can do exactly the same with divs. Say goodbye to annoying short columns! You can read my article on equal height columns if you want to see how this is done.</p>
<h2>No Images</h2>
<p>This layout requires no images. Many CSS website designs need images to colour in the column backgrounds but that is not necessary with this design. Why waste bandwidth and precious HTTP requests when you can do everything in pure CSS and XHTML?</p>
<h2>No JavaScript</h2>
<p>JavaScript is not required. Some website layouts rely on JavaScript hacks to resize divs and force elements into place but you won't see any of that nonsense here. The JavaScript at the bottom of this page is just my Google Analytics tracking code, you can remove this when you use the layout.</p>
<h2>Resizable text compatible</h2>
<p>This layout is fully compatible with resizable text. Resizable text is important for web accessibility. People who are vision impaired can make the text larger so it's easier for them to read. It is becoming increasingly more important to make your website resizable text compatible because people are expecting higher levels of web accessibility. Apple have made resizing the text on a website simple with the pinch gesture on their multi-touch trackpad. Is your website text-resizing compatible?</p>
<h2>No Quirks Mode</h2>
<p>This liquid layout does not require the XML declaration for it to display correctly in older versions of Internet Explorer. This version works without it and is thus never in quirks mode.</p>
<h2>No IE Conditional Comments</h2>
<p>Only one stylesheet is used with this layout This means that IE conditional comments are not needed to set extra CSS rules for older versions of Internet Explorer.</p>
<!-- Column 2 end -->
</div>
<div class="col3">
<!-- Column 3 start -->
<h2>Browser Compatibility</h2>
<p>This 3 column liquid Layout has been tested on the following browsers:</p>
<h3>iPhone & iPod Touch</h3>
<ul>
<li>Safari</li>
</ul>
<h3>Mac</h3>
<ul>
<li>Safari</li>
<li>Firefox</li>
<li>Opera 9.25</li>
<li>Netscape 9.0.0.5 & 7.1</li>
</ul>
<h3>Windows</h3>
<ul>
<li>Firefox 1.5, 2 & 3</li>
<li>Safari</li>
<li>Opera 8.1 & 9</li>
<li>Google Chrome</li>
<li>Explorer 5.5, 6 & 7</li>
<li>Netscape 8</li>
</ul>
<h2>Valid XHTML strict markup</h2>
<p>The HTML in this layout validates as XHTML 1.0 strict.</p>
<h2>This layout is FREE for anyone to use</h2>
<p>That's right, you don't have to pay anything. If you are feeling generous however, link back to this page so other people can find and use this layout too.</p>
<p>Download this layout (25kb zip file).</p>
<h2>Centered menus compatible</h2>
<p>This layout is fully compatible with my centered menus.</p>
<!-- Column 3 end -->
</div>
</div>
</div>
</div>
<div id="footer">
<p>This page uses the Perfect 'Holy Grail' 3 Column Liquid Layout by Matthew James Taylor. View more website layouts and web design tips.</p>
</div>
</body>
</html>
remove the bullets nor add a block behind the text.
Using
list-style: none;
in your CSS to set ALL ul elements to not have bullet points use the following
ul{
list-style: none !important;
}
elements in your html, will stop you from having the bullet points, you have done this to your specific header UL but not to any subsequent ones.
I'm trying to achieve the following :
I have image and I need border 1px black and 1px white on the img to achieve some effects . And on hover 3px border that on click become active class and change the hover to fixed border of 3px.
What is the best way to that ?
I tried to do that with padding 3px on the a link
And gave the following :
a {
float:left;
background-color:white;
padding:3px;
}
and
img {
max-width:100%;
float:left;
}
The problem is that the border is not equal and little bit move the img.
Also When I hover all the UI I need opacity 0.5 and it's make problem with the a
So I looking for the best solution for 3 borders with hover and active/non active without affecting the img
my code is :
<ul>
<li>
<div>
<a class="active">
<img>
</a>
</div>
</li>
<li>
<div>
<a>
<img>
</a>
</div>
</li>
</ul>
Not sure if this is what you had in mind, but I hope that the output below can help you get started.
The main trick here is to put your <img> inside 3 divs:
the innermost div is your white border
the middle div is your black border
the outermost div is a transparent 1px border
The last one is required so that the image doesn't move--since the border is already there and will not have to be generated when you hover.
So when you hover: the outer div becomes white, the middle div (previously black) becomes white, and the last div is, well, still white. Voila! You have your "3px solid white" border on hover.
in order to toggle an active class that will stick, then you will need javascript. In this case, I just went ahead and used JQuery.
last note: since I eliminated your <a> tag, I just put a cursor:pointer rule on your outermost div so that it will still look like you are hovering on a link. You can just place whatever is your link action in your javascript onclick rule.
Hope this helps!
$('.outer').on('click',function(){
$('.active').removeClass('active');
$(this).addClass('active');
});
body {
background:gray;
}
li {
margin-top:15px;
}
li * {
transition:all ease 0.3s;
}
li:hover {
cursor:pointer;
}
.outer {
border:1px solid transparent;
}
.outer:hover,.outer:hover > .black-border {
border:1px solid white;
}
.outer:hover img {
opacity:0.5;
}
.active {
border:1px solid white;
}
.active > .black-border {
border:1px solid white;
}
img {
max-width:100%;
padding:0;
margin:0;
vertical-align:top;
background-size:cover;
}
.black-border {
border:1px solid black;
}
.white-border {
border:1px solid white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li>
<div>
<div class="outer">
<div class="black-border">
<div class="white-border">
<img src="https://cdn.pixabay.com/photo/2014/03/29/09/17/cat-300572_960_720.jpg">
</div>
</div>
</div>
</div>
</li>
<li>
<div>
<div class="outer">
<div class="black-border">
<div class="white-border">
<img src="https://www.petfinder.com/wp-content/uploads/2012/11/155293403-cat-adoption-checklist-632x475-e1354290788940.jpg">
</div>
</div>
</div>
</div>
</li>
</ul>
I'm trying to create something that looks like this:
so far I have: http://jsfiddle.net/ePse6/
Without using something like: margin-top:-25px;, how can I position the Edit/Delete links to be on the right of the title (the part that says "iPhone" or "Android") and have both the title and links halfway between the borders?
Thanks!
just like most of answers, here i come with text-align:right and float:left .
I reduced code to minimal and plain CSS for your actual structure and to make it clear to you : http://jsfiddle.net/ePse6/7/
ul , a { /* basic reset we need */
padding:0;
margin:0;
color:gray;
text-decoration:none;
}
.mini > ul > li {
display:block;/* reset from list-item */
border-bottom:solid;
text-align:right;
overflow:hidden;/* wraps floatting element within */
}
.mini > ul > li> h3 {
float:left;
margin:0;
}
.mini > ul > li ul,
.mini > ul > li li {
display:inline-block;
}
Why not use something simple and really handy?
I have removed all of your messy code, and have created a new fiddle for you.
http://jsfiddle.net/afzaal_ahmad_zeeshan/ePse6/4/
I have used just a few lines of code, I have used a div and inside that, I have used 2 paragraphs to seperate each of them. Then inside that I used span element to seperate the right and left floating elements.
Using CSS I selected the classes and then styled them to get the desired input!
Here is the code:
<div>
<p>
<span class="left">Android</span><span class="right">Delete Edit</span>
</p>
<p>
<span class="left">iPhone</span><span class="right">Delete Edit</span>
</p>
</div>
CSS is as:
p {
border: 1px solid #333; // border that you wanted!
padding: 20px; // padding all around the element
padding-bottom: 40px; // padding at the bottom of the element
}
.left {
float: left; // making the elements float at the left
}
.right {
float: right; // floating elements at the right side
}
You can go to the fiddle page, and check for the design of the layout now. It was a simple thing. Hope its what you wanted.
This is without the lists. Just some CSS to do the trick: http://jsfiddle.net/Lg96p/
CSS:
.wrap{
width:100%;
border-bottom:solid 1px #666666;
margin-bottom:20px;
padding-bottom:10px;
}
.title{
font:bold 16px arial;
}
.fl{
float:left;
}
.fr{
float:right;
}
.lnk{
color:#6c6c6c;
display:inline-block;
text-align:right;
margin:0 10px 0 0;
text-decoration:none;
font:normal 14px arial;
}
HTML:
<div class="wrap fl">
<div class="title fl">iPhone</div>
<div class="fr"><a class="lnk" href="">Edit</a><a class="lnk" href="">Delete</a></div>
</div>
<div class="wrap fl">
<div class="title fl">Android</div>
<div class="fr"><a class="lnk" href="">Edit</a><a class="lnk" href="">Delete</a></div>
</div>
You should create two columns that fill the parent div. Make them both float:left; and for the right column you can align the text to the right text-align:right; or put two divs in it with float:right; for edit and delete.
Here is my fiddle: http://jsfiddle.net/ePse6/5/
Whatever you put into the columns or how to format it is up to you. But from here you have 2 columns independently next to each other.
If you want multiples of these stacked on top of each other i would change the container to a class and just add multiple of these containers with the columns to keep it tidy and readable. Like in this fiddle: http://jsfiddle.net/ePse6/6/
HTML:
<div class='container'>
<div class='leftCollumn'>
Iphone
</div>
<div class='rightCollumn'>
<a hreft="">Edit</a><a hreft="">Delete</a>
</div>
</div>
<div class='container'>
<div class='leftCollumn'>
Iphone
</div>
<div class='rightCollumn'>
<div class="button">Edit</div><div class="button">Delete</div>
</div>
</div>
CSS:
.container
{
width:600px;
margin:auto;
}
.leftCollumn
{
float:left;
width:400px;
background-color:#999;
}
.rightCollumn
{
float:left;
width:100px;
text-align:right;
background-color:#CCC;
}
.rightCollumn a
{
margin-left:10px;
margin-right:5px;
}
.button
{
margin-left:10px;
margin-right:5px;
background-color:#000;
color:#FFF;
float:right;
}
Actually I want to give hover to div which is inside hyperlink but I don't know how to in css.
These divs actually have background images attached to them in css.
<div class="header_menu">
<div class="foa_logo"><img src="images/FOA-Logo.jpg"/></div>
<div class="address"></div>
<div class="home"></div>
<div class="about"> </div>
<div class="services"></div>
<div class="contact"></div>
</div>
div {
width:100px;
transition: width 2s;
}
div:hover {
width:200px;
}
replace div with .foa_logo if you want to select just that class.
I've created a jsfiddle for you showing how to do the hover you want. I removed the divs in the hyperlinks, because they are not useful. You can simply set the styles for the a tags and then you get your hovers
http://jsfiddle.net/FHWb6/
.header_menu a {
display:block;
height:40px;
width:100px;
line-height:3;
text-align:center;
font-family:Arial;
font-size:14px;
text-transform:uppercase;
float:left;
position:relative;
background:url(); /*put your image here*/
background-color:#CC0;
color:#FFF;
text-decoration:none;
}
.header_menu a:hover {
background:url(); /* put your hover image or position here */
background-color:#ececec;
color:#000;
}
I added some extra code in there just to do some base level styling - color, height and width will most likely change for you.
Try this:
element:hover {
property: value;
}
By this, you can change the CSS properties of the elements when they are hovered over!
So for you, you will try it as:
.home:hover { // on the home div..
// all the changes here
}
I have two DIVs one contain new release and must, another one contain whole data.
both div have a red border. I remove bottom border of first div.
I want to remove the border where I marked with red rectangle:
Have your active tab have position:relative and z-index higher then the content box. Then add border-bottom: 1px solid white and give it margin-bottom: -1px.
From a current project: http://jsfiddle.net/aVZLH/1/
Maybe you have some additional work for IE. But rudimentary it should show you a way to solve your problem... Without additioanl markup in your document.
<ul>
<li class="current">Tab #1</li>
<li>Tab #2</li>
</ul>
<div class="content">
<p>MY AWESOME CONTENT</p>
</div>
/*CSS*/
ul {
overflow: hidden;
position: relative;
top: 1px;
z-index: 2;
}
li {
color:#fff;
background:red;
float:left;
border:1px solid red;
padding:5px 10px;
position:relative;
top:1px;
}
.current {
background: #FFFFFF;
border-bottom: 0;
color: red;
}
.content {
padding:20px;
border:1px solid red;
position:relative;
z-index:1;
}
You can create another div to occupy the space to the right of the "Must" tab. Set this div's bottom border to "1px solid red". Then, remove the border-top from the news box, and the border-bottom from the tabs themselves.