I'm trying to build a basic bar that contains 5 buttons, every button is consist of an icon and below text that describes the icon.
I want that all the images will be on the same line and the descriptions will be underneath.
<img src=phone.png />call office
<img src=circle.png />link to website
<img src=book.png />add to contacts
in this code for example, "call office" should be below the first img, "link to website" below the second and so on but it writes the description but the description appears in the same line with the icons, every description next to itws icon.
can you help?
thx
Do it like this:
The icons/links are placed in a list, the HTML is cleaned up, and I've added a bit of CSS to show how it can look
ul {
list-style-type: none;
}
li {
display: inline-block;
margin: 1em;
}
li a {
display: block;
text-align: center;
}
li a img {
margin: 0 auto;
display: block;
width: 3em;
height: 3em;
}
<ul>
<li><img src=phone.png><br>call office</li>
<li><img src=circle.png><br>link to website</li>
<li><img src=book.png><br>add to contacts</li>
</ul>
I would change the HTML as well. Put just the text in there, because the images have no semantic value. Using CSS you can show the icons, and you don't even need an element for that. Just use the ::before pseudo-element.
nav.social {
text-align: center;
}
nav.social a {
display: inline-block;
padding: 3px;
}
nav.social a::before {
content: "";
display: block;
height: 32px;
background: url(http://www.phonebook.com/favicon.ico) top center no-repeat;
}
nav.social a.website::before {
background-image: url(http://stackoverflow.com/favicon.ico);
}
nav.social a.vcard::before {
background-image: url(https://en.wikipedia.org/favicon.ico);
}
<nav class="social">
<a class="phone" href="tel:036781223333" title="call us">call office</a>
<a class="website" href="http://www.bgasgdhen.com/" title="website">link to website </a>
<a class="vcard" href="advbagsgadron.vcf" title="add to contacts">add to contacts </a>
</nav>
Related
In the following coding, the listmark is placed on top of the image only if it is displayed in Chrome.
(Float is effective for text, it will be displayed on the right side of the image without problems)
Also, when refresh with F5, the listmark will be displayed on the right side of the image without problems.
To prevent the listmark from being placed on top of the image from the beginning, could someone please tell me what to do?
img {
float: left;
}
ul li {
margin-left: 20px;
}
<div>
<img src="images/sample.jpg" alt="sample" width="50%" />
<ul>
<li>aaa</li>
<li>bbb</li>
<li>ccc</li>
<li>ddd</li>
<li>eee</li>
</ul>
</div>
Updates:
When the list gets long, I want the lists wrap images like below.
https://embed.plnkr.co/uo1u4YOQHAWpFEO117QG/
img {
display: inline-block;
}
ul{
display: inline-block;
}
ul li {
margin-left: 20px;
}
<div>
<img src="images/sample.jpg" alt="sample" width="50%" />
<ul>
<li>aaa</li>
<li>bbb</li>
<li>ccc</li>
<li>ddd</li>
<li>eee</li>
</ul>
</div>
img {
display: inline-block;
}
ul{
display: inline-block;
}
Try this.
You can try to float your <ul> like so:
ul{
float: left;
width: calc(50% - 20px);
}
That should float everything and the ul will always be on the right side of the image.
I am trying to show an edit icon on a cells hover state, using font awesome.
How can make the class name unique so I can target it with css for each row?
import {Icon} from 'react-fa'
if(this.props.day.achievements) {
listItems = this.props.day.achievements.map((achievement) => (
<div className="cell" key={achievement + "_achievements"}>
{achievement}
<div className="edit">
<a href="#">
<Icon name="pencil-square" className="edit" />
</a>
</div>
</div>
))
}
I am using the following css:
.cell:hover .edit {
display: block;
}
.edit {
padding-top: 7px;
padding-right: 7px;
position: absolute;
right: 0;
top: 0;
display: none;
}
.edit a {
color: #000;
}
How can I display the icon for each cell?
Since you're using position:absolute on the edit wrapper, try adding position:relative to the .cell. I suspect your icons ARE showing but they're all floating up to the top overlapping with each other.
Using CSS, I want to
position 2 images next to each other on the first line
position 3 images on the second line - see attached picture.
I have tried using the CSS below, but this results in the 3rd image being on a row of its own.
.profile-pic-row:nth-of-type(3){
display: block;
}
.profile-pic-row {
display: inline-block;
}
How can I get the 3rd image to line up with the following 4th and 5th images?
When you define the third image to be "block" - the block definitions put it in a different line, you need to put "inline-block".
If you want that the 3rd pic will be in a separate line from the previous line from 1st and 2nd pics, you can you `"clear: left":
.profile-pic-row{
display: inline-block;
float: left;
}
.profile-pic-row:nth-of-type(3){
clear: left;
}
Or put 2 pictures in one div and 3 pictured in another div and then define the divs to be full row (with "display:block" or "width:100%").
<div class="firstRow">
<img class="profile-pic-row" />
<img class="profile-pic-row" />
</div>
<div class="secondRow">
<img class="profile-pic-row" />
<img class="profile-pic-row" />
<img class="profile-pic-row" />
</div>
Also, you can put every image in a div or a different component, and define width of 50% to the first and second pics, and width of 33% to the pics for the second row.
Here's my approach with a single <ul> and the content always centered
Codepen demo
Markup
<ul>
<li><img src="http://lorempixel.com/100/100/cats/" /></li>
<li><img src="http://lorempixel.com/100/100/cats/" /></li>
<li><img src="http://lorempixel.com/100/100/cats/" /></li>
<li><img src="http://lorempixel.com/100/100/cats/" /></li>
<li><img src="http://lorempixel.com/100/100/cats/" /></li>
</ul>
CSS
* { box-sizing: border-box; }
ul {
list-style: none;
font-size: 0;
margin: 0;
padding: 0;
text-align: center;
}
li {
display: inline-block;
padding: 10px;
}
/* first and second list-item are 50% wide */
li:nth-child(1), li:nth-child(2) { width: 50%; }
/* change alignment of inner pictures */
li:nth-child(1) { text-align: right; }
li:nth-child(2) { text-align: left; }
/* just a bit of responsiveness */
li img { max-width: 100%; }
li:nth-child(n+3) { max-width: 30%; }
The trick here is to set the width of the first two list-items to 50% and change their alignment so the first <li> has text-align: right aligned and the second text-align: left (the first two images appear as they were side-by-side)
Result
I am programing a webpage with html and CSS. My pseudo class :hover stopped working on my webpage, but :focus still works. Hover was working fine, and then I made an unrelated edit (added an image to one of my blocks), and noticed it had stoped working. I deleated my last change and it still did not work.
I have checked everything and ran both the html and css through validators and there are no errors other than something about using character encoding, but I know it worked fine without that. It really makes no sense!
I will show my page and my code. Keep in mind this is my very first webpage, I know that I did not optimize my background images properly, and may have some unnecessary divs, but I feel pretty good about it considering a week ago I did not know what html was. I have heavily commented and organised my CSS, you can find my hover code near the top along with the rest of the none classes/ID's. The hover link is the only link on the webpage on the sidebar.
http://www.adrianhoulewebprojects.com/HomePage.html
Here is my HTML
<!--Home Page for adrianhoulewebpojects.com Version 1.0-->
<!--Written by Adrian Houle-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/HomePageStyle.css">
<title>Adrian Houle Web Projects</title>
</head>
<body>
<div id="Sidebar">
<h3>Projects</h3>
<ul>
<li>
Under Construction
</li>
<li>Unfinished Project #2</li>
<li>Unfinished Project #3</li>
<li>Unfinished Project #4</li>
<li>Unfinished Project #5</li>
</ul>
</div>
<div class="box">
<div class="HalfSpacer"></div>
<div class="TransBox" id="Header">
<h1>Welcome to<br>AdrianHouleWebProjects.com</h1>
</div>
<div class="Spacer"></div>
<div class="TransBox" id=About>
<h2>About:</h2>
<p>Welcome to my website. I had a bit of time over the holidays and decided to finally get around to learning web programming. The purpose of this website is to give me a place to practice and display what I learn in the form of web projects. I may also be making some blogs that will also serve to showcase my travelling and hobbies.</p>
</div>
<div class="Spacer"></div>
<div class="TransBox" id="NewStuff">
<h2>Coming Soon</h2>
<ul>
<li>
<h3>Australia Travel Blog</h3>
<img src="http://www.adrianhoulewebprojects.com/img/AustralianFlag100by50.gif" alt="Australian Flag" >
<p>2013-2014 Australia Travel Blog coming soon.</p>
</li>
</ul>
</div>
<div class="Spacer"></div>
<div class="TransBox" id="Contact">
<h2>Contact Info:</h2>
<p class="Italic">Please report any compatibility, accessibility, or security issues to:</p>
<p>Adrian Houle</p>
<p>adrianhoule#gmail.com</p>
</div>
<div class="Spacer"></div>
<div class="TransBox" id="Footer">
<p>Website by Adrian Houle</p>
</div>
</div>
<div class="BottomBorder"></div>
</body>
</html>
Here is my CSS
/***************************************** Info *********************************************************/
/*Style Sheet for HomePage of adrianhoulewebprojects.com*/
/*Written by Adrian Houle*/
/*For any issues with my website (compatibility, accessibility, white-hat reports) feel free to contact me at
adrianhoule#gmail.com
/*Page Purpose: Create a homepage that welcomes users to my website and directs them to various projects*/
/***********************************************************************************************************/
/************************************* Table of Contents **************************************************/
/*CSS layout*/
/* -none specific elements*/
/* -classes*/
/* -ID's and children of ID's*/
/* -Other*/
/************************************************************************************************************/
/************************************** CSS code ****************************************************/
/* -none specific elements ***********************************************************************************/
p {
font-size: large;
font-weight: bolder;
}
a {
color: blue;
}
a :hover, :focus{
background-color: yellow;
text-decoration: none;
font-size: larger;
}
/* -classes **************************************************************************************************/
/*Element that contains everything except the sidebar and has the main background image.*/
.box {
display: block;
position: relative;
width: 100%; /*test and adjust to keep it from expading the browser*/
height: 100%;
border: 3px solid black;
right: 0;
top: 0px;
padding: 0;
background-image: url(http://www.adrianhoulewebprojects.com/img/CautionStripes.png);
}
/*Allows for synchronised space adjustment between elements*/
.Spacer {
position :relative;
height: 100px;
}
/*Allows for synchronised space adjustment between elements*/
.HalfSpacer {
position :relative;
height: 30px;
}
/*Every element that contains text belongs to this class*/
/*This class has nothing to do with transgender boxes, or gender boxes in general*/
.TransBox {
width: 70%;
padding: 1em;
z-index: 1;
left: 20%;
position: relative;
background-image: url(http://www.adrianhoulewebprojects.com/img/SteelPlate.jpg);
moz-box-shadow: 0 0 5px 5px #888; /*shadow effect with cross compatibility*/
webkit-box-shadow: 0 0 5px 5px#888;
box-shadow: 0 0 5px 5px #888;
}
.Italic {
font-style: Italic;
}
/* -ID's and children of ID's********************************************************************************/
/*Sidebar, to be fixed to the left hand side of the screen. Must allow conent to the right of it*/
#Sidebar {
height: 100%;
width: 10%;
left: 0px;
top: 0px;
padding: 2%;
display: inline;
position: fixed;
background-image: url(http://www.adrianhoulewebprojects.com/img/SteelPlate.jpg);
border-style: solid;
border-width: 3px;
z-index: 2;
}
#Sidebar ul {
padding-left:0;
}
#Sidebar li {
margin: 10%;
}
/*Header text*/
#Header h1 {
text-align: center;
}
#Footer p {
text-align: center;
}
/* -Other (empty)*****************************************************************************************/
Thank you for any help.
CSS is very touchy about putting extra spaces in it. Combine a with :hover like this:
a:hover, a:focus{
background-color: yellow;
text-decoration: none;
font-size: larger;
}
Also want to make it a:focus unless you want every element to be affected.
Remove the space between a and :hover
a:hover{
background-color: yellow;
text-decoration: none;
font-size: larger;
}
I have a strange bug when looking at my homepage in Chrome. The bug doesn't seem to appear when I try to edit it with CSSEdit:
I attached the pictures to show you what I mean. Those "points" next to the icons are linked as well.
What could be causing this error?
Thanks for the help!
EDIT sure here's the code (the page isn't online):
<div class="rss">
<p>
<a href="http://linkto">
<img src="/images/facebook.png" alt="Find me on facebook" />
</a>
<a href="http://linkto">
<img src="/images/twitter.png" alt="Follow me on twitter" />
</a>
<a href="http://linkto">
<img src="/images/rss.png" alt="Subscribe to RSS Feed" />
</a>
</p>
</div>
which is wrapped in a div class called footer. And the CSS
.site .footer {
font-size: 80%;
color: #666;
border-top: 4px solid #eee;
margin-top: 2em;
overflow: hidden;
}
.site .footer .rss {
margin-top: 0em;
margin-right: -.2em;
float: right;
}
.site .footer .rss img {
border: 0;
}
Sorry for the strange formatting.
Those "points" are the text-decoration:underline portion of your CSS being applied to <a> tags. The reason you only see part of it is because the image you are using is covering the majority of it.
Try putting this in your CSS:
.rss a { text-decoration:none }
.rss a img { border:none; outline:none }