so I've created a snippet of layout that I'd like to re-use in various places in my code. JSFiddle with what it looks like normally with the following dom structure: https://jsfiddle.net/64x9udcr/
<a class="stamp">
<div class="stamp-left"><span>0023f23f2</span></div>
<div class="stamp-right"><span>The quick brown fox jumped over the lazy dog</span></div>
</a>
Basicly an identifier on the left, with a description on the right, not too complicated. It's also inline, so it can be included in a line of text like an identifier.
Ex:
What I'm having trouble with is getting it to wrap if necessary. The following is an image of what I'd like to happen when wrapping is needed. A would be preferred, but if not possible, then B.
Any pointers as to what combination of CSS I should be using?
Used flex method with few little changes in your code.
https://jsfiddle.net/64x9udcr/2/
.label,
.stamp {
border-radius: 0.25em;
color: rgb(255, 255, 255);
display: inline;
font-size: 75%;
font-weight: bold;
line-height: 1;
padding: 0.2em 0.6em 0.3em;
text-align: center;
vertical-align: baseline;
white-space: nowrap;
}
.stamp {
border: 1px solid rgb(218, 218, 218);
color: inherit;
display: inline-block;
font-size: inherit;
font-weight: inherit;
margin-bottom: 0.1em;
padding: 0;
}
.stamp .stamp-left,
.stamp .stamp-right {
display: inline-block;
padding: 0.2em 0.6em;
}
.stamp .stamp-left {
background: rgb(218, 218, 218) none repeat scroll 0 0;
font-family: "courier";
}
.select2-results__option--highlighted .stamp .stamp-left {
color: rgb(51, 122, 183);
}
a.stamp:hover {
border-color: rgb(35, 82, 124);
}
a.stamp:hover .stamp-left {
background-color: rgb(35, 82, 124);
color: rgb(255, 255, 255);
}
a.stamp:hover .stamp-right {
color: rgb(35, 82, 124);
}
.container {
display: flex;
width: 100%;
}
.stamp {
max-width: 100%;
overflow: hidden;
min-width: 200px;
}
<div class='container'>
<a class="stamp">
<div class="stamp-left"><span>0023f23f2</span>
</div>
<div class="stamp-right"><span>The quick brown fox jumped over the lazy dog</span>
</div>
</a>
</div>
Related
This is all my code (the code seems very messy because I just started learning about 2/3 weeks ago). I cant seem to style the anchor elements. I even tried putting a class on them and it also doesn't works. I'm kinda new to this thing.
#import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Merriweather:wght#700&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Bree+Serif&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Inter:wght#500&display=swap');
body {
height: 100%;
margin: 0;
padding: 0;
background: #bbb;
}
.ex-house {
padding: 0;
display: block;
margin: 0 auto;
max-height: 100%;
max-width: 100%;
opacity: 0.8;
}
.house-dh {
position: absolute;
top: -20%;
left: 2%;
padding: 0px;
margin: 0px;
color: rgb(255, 255, 255);
font-family: 'Bree serif';
font-size: 125px;
text-align: center;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
.about-gnco1 {
position: absolute;
color: rgb(255, 255, 255);
font-family: 'Inter';
font-size: 35px;
text-align: left;
margin: 0px;
padding: 0px;
left: 2%;
top: 20%;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
/* this is my code for the style element i think i did it right but when i run it. the a href element dosent change */
.front-button {
font-family: 'Bebas Neue';
font-size: 20px;
color: white;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
.front-button a {
margin: 0 20px;
}
<body>
<div class="front">
<img class="ex-house" src="https://via.placeholder.com/80" alt="dreamhouse">
<div class="house-dh">
<p>grandnew.co</p>
</div>
<div class="about-gnco">
<p class="about-gnco1">Is here to help you<br> build your own<br> Dream House.</p>
</div>
</div>
</div>
<div class="front-button">
CUSTOMIZE
DESIGNS
PLANS
ABOUT US
</div>
</body>
if you mean underline of link for that you can use the method text-decoration for examplea{text-decoration:none} this code will remove any decorations of a tag so if you wanna use this function for all a tags you will write a{text-decoration:none} so if you wanna set decoration of specific tag you can give a class on the tag before you can change something example
HTML
go to stackoverflow
<a class="a-tag" href="https://stackoverflow.com">go to stackoverflow</a>
CSS
a{ //for all <a> tags
text-decoration:none
}
.a-tag{ // only for tag who have the a-tag class
text-decoration:none
color:black;
}
This works for me. The style of the text in the '.front-button a', not in '.front-button'
.front-button a {
margin: 0 20px;
font-family: 'Bebas Neue';
font-size: 20px;
color: red;
text-shadow: 2px 2px 3px rgba(241, 238, 53, 0.5);
}
link style
More about link styles:
https://www.w3schools.com/css/css_link.asp
How do I change link style in CSS?
I want to display the result like this: Check this image please
What can I do make the text inside <p id='info'> responsive? Note: The whole text must be on the right side and must break the words in an overflown condition. Please help me.
When I tried to minimize the screen size of Chrom to check it's responsive-capability, it shows that the whole #infohead1 breaks it's line instead of breaking wording inside <p id='info'>
.infoheader {
background: rgb(187, 183, 183);
padding: 6px;
text-align: left;
}
#image {
display: inline;
vertical-align: middle;
}
#infohead1 {
display: inline-block;
vertical-align: middle;
}
#info {
display: inline-block;
word-wrap: break-word;
font-size: 14px;
font-family: 'Balsamiq Sans';
cursor: pointer;
padding: 1px;
}
#ans {
color: rgb(0, 78, 33);
}
.img {
cursor: pointer;
width: 301px;
border: 7px solid rgb(14, 14, 14);
margin: 5px;
}
<div class='infoheader'>
<div id='image'>
<img src='https://i.stack.imgur.com/YRu2w.png' alt='{{show_site}}' title='{{show_site}} - Homepage Interface'
class='img'>
</div>
<div id='infohead1'>
<p id='info' style='font-size:19px;'>Google Adsense Approval Probability: <span id='ans'>80%</span></p>
<p id='info' style='font-size:19px;'>Total SEO Score: <span id='ans'>35%</span></p>
<p id='info' style='font-size:19px;'>Site Structure Score: <span id='ans'>80%</span></p>
</div>
</div>
I am having a frustrating CSS problem- basically I have an image that needs to be exactly inline (not above or below) text that I have all within an a href. HTML-
<li><img class= "emoji" src="../images/emojis/1f642.png"/><p class="emojiText">Pretty good</p></li>
produces this:
You can see that the image is the right size but slightly too far up from the text. I have rearranged my html and stuck the text within its own <p>, moved the image, everything. Nothing has worked. My current CSS:
.emoji {
height: 18px;
width: 18px;
margin-top: 8px;
margin-right: 8px;
margin-left: 5px;
}
.emojiText {
margin-bottom: 10px;
display: inline;
}
.status li a {
text-indent: 5px;
display: block;
width: 250px;
color: white;
height: 35px;
font-family: 'Source Sans Pro', sans-serif;
font-size: 16px;
text-align: left;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: 0;
border-top: 1px solid rgba(255, 255, 255, 0.3);
background-color: rgba(255, 255, 255, 0.1);
position: relative;
padding-top: 0px;
text-decoration: none;
}
the last block affects both but no matter how I play with the margins I can't fix the image-text align problem. What can I do to fix this?
EDIT:
If you want the emoji and text to align their center-points...
.emoji,
.emojiText {
display: inline-block;
vertical-align: middle;
}
This is what you expecting...
<style>
a { display:inline-block; background:#52D4A4; text-align:center; text-decoration:none; padding:10px; }
a img { display:block; margin:0 auto; }
</style>
<img src="http://www.cmegroup.com/etc/designs/cmegroup/cmegroupClientLibs/images/iconFacebook.png">Pretty good
UPDATE: Here's a Fiddle: https://jsfiddle.net/720v4zdy/8/
I'm customizing a tumblr blog to match someone's site and it's almost in good shape. We started with a theme that already matched it closely and then made some changes in CSS.
The last problem I can't solve is how to make the navigation bar stretch the entire page while containing all of the links in a max-width of 1024px.
Here's the tumblr blog WIP: http://craftysheepblog.tumblr.com/
I want the navigation bar to stretch the entire page, but the links to be contained with a max-width of 1024px. The trouble here is I only have one DIV to do this with, so I'm not quite sure how to make it happen.
I'm using this currently, which works somewhat. It gets ugly when you make the browser window smaller though.
#top nav {
background-color: rgb(45, 50, 51);
color: white;
text-align: left;
padding: 11px 22%;
margin-top: 20px;
width: 100%;
}
You can set the nav to max width: 1024px and fill the "gaps" on the sides with ::before and ::after pseudo elements. You'll need to hide the overflow on header#top to avoid sideways scrolling, because the pseudo elements are set wider than the content.
This does rely on you setting the height of your nav and following suit with the <a> (height, line-height, etc.) ...
Also - tweak some more; there is a 600px break point in your CSS on the live site that will interfere with this (along with a lot of your extra CSS that I didn't clean up).
body {
color: rgb(38, 39, 43);
font-family: "Open Sans", "sans-serif", Arial;
font-weight: 300;
font-size: 14px;
line-height: 1.42857143;
margin: 0;
}
#top {
overflow: hidden;
}
#top .title {
font-family: "Open Sans", "sans-serif", Arial;
font-size: 30px;
text-align: left;
font-weight: lighter;
margin-top: 18px;
display: block;
width: 100%;
max-width: 1024px;
margin-left: auto;
margin-right: auto;
}
#top nav {
background-color: rgb(45, 50, 51);
color: white;
text-align: left;
max-width: 1024px;
margin: 50px auto 20px;
height: 50px;
width: 100%;
border-width: 0;
padding: 0;
position: relative;
}
#top nav::before{
background: rgb(45,50,51);
content: "";
display: block;
position: absolute;
height: 50px;
width: 100%;
right: 100%;
}
#top nav::after{
background: rgb(45,50,51);
content: "";
display: block;
position: absolute;
height: 50px;
width: 100%;
left: 100%;
top: 0;
}
#top nav a {
border-bottom: 1px solid rgba(255, 255, 255, 0);
font-size: 13px;
letter-spacing: 1px;
font-weight: 600;
margin: 0px 15px;
}
#top nav a {
color: #fff;
font-size: 13px;
text-transform: none;
font-family: "Open Sans", "sans-serif", Arial;
font-weight: 300;
border: 0;
display: inline-block;
padding: 0 1em;
margin: 0;
height: 50px;
line-height: 50px;
}
#top nav a:hover {
color: #52A708;
}
#top .headimg {
display: none;
}
<header id="top">
<div class="row">
<div class="small-12 small-centered columns">
<a href="/" class="active">
<div class="title">Page Title</div>
</a>
<nav>
<a class="page" href="#">Link 1</a><a class="page" href="#">Link 2</a><a class="page" href="#">Link 3</a>
</nav>
</div>
</div>
</header>
How about using max-width: 1024px;
The best way to do this is to use a ul inside of a div as your navigation bar. The ul can contain all of your links. That way, the div can have a width that spans the entire page while the unordered list has a max width of 1024px.
Example code:
<html>
<head>
<style>
#nav {
width: 100%;
height: 20%;
}
#nav-links {
max-width: 1024px;
}
</style>
</head>
<body>
<div id="nav">
<ul id="nav-links">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>...</li>
</ul>
</div>
</body>
</html>
Then you can style your ul as a nav bar however you like. Here's a good link for that: http://www.w3schools.com/css/css_navbar.asp
With the amount of information you have shared it is hard to say. Obviously the cleanest way to accomplish this is to insert another element (div or otherwise) around these child elements, and assign it a max-width... however this does not sound as if it is an option for you?
If you know how many elements you want to make up the 1024px, you could assign their widths manually (i.e. give each of the four children a width of 256px, or something similar).
If you do not know any of these things, and your options for the space are limited, Javascript is your best option. You could write a script that counts the children, and either assigns their widths appropriately or inserts clears at the proper location.
If you expand your question to target a specific approach, I'm sure myself and the many gurus on here will be able to give you more specific guidance.
Use flexbox: https://philipwalton.github.io/solved-by-flexbox/
The links should stretch as normal but start to shrink when they each exceed 341px which is 1023px as a total width.
Note: Snippet best viewed in Full Page mode.
Relevant CSS
#top nav {
background-color: rgb(45, 50, 51);
color: white;
text-align: left;
padding: 11px 22%;
margin-top: 20px;
display: flex;
flex-flow: row nowrap;
justify-content: baseline;
#top nav a {
border-bottom: 1px solid rgba(255, 255, 255, 0);
font-size: 13px;
letter-spacing: 1px;
font-weight: 600;
margin: 0px 15px;
flex: 0 1 341px;
}
body {
color: rgb(38, 39, 43);
font-family: "Open Sans", "sans-serif", Arial;
font-weight: 300;
font-size: 14px;
line-height: 1.42857143;
}
.row {
max-width: 100%;
}
#top {
margin-top: 0px;
}
#top .title {
font-family: "Open Sans", "sans-serif", Arial;
font-size: 30px;
text-align: left;
font-weight: lighter;
margin-top: 18px;
display: block;
width: 100%;
max-width: 1024px;
margin-left: auto;
margin-right: auto;
}
#top nav {
background-color: rgb(45, 50, 51);
color: white;
text-align: left;
padding: 11px 22%;
margin-top: 20px;
display: flex;
flex-flow: row nowrap;
justify-content: baseline;
}
#top nav a {
border-bottom: 1px solid rgba(255, 255, 255, 0);
font-size: 13px;
letter-spacing: 1px;
font-weight: 600;
margin: 0px 15px;
flex: 0 1 341px;
}
#top nav a {
color: #fff;
font-size: 13px;
text-transform: none;
text-decoration: none;
font-family: "Open Sans", "sans-serif", Arial;
font-weight: 300;
}
#top nav a:hover {
color: #52A708;
}
#top .headimg {
display: none;
}
#posts {
width: 100%;
max-width: 1024px;
margin-left: auto;
margin-right: auto;
}
.column,
.columns {
padding: 0;
}
#posts article:nth-child(1) {
padding-top: 20px;
}
#posts article .title {
font-family: "Open Sans", "sans-serif", Arial;
font-size: 36px;
color: rgb(38, 39, 43);
text-align: center;
font-weight: 500;
}
#posts article footer {
display: none;
}
#paginate {
display: none;
}
#bottom {
border: none;
}
#bottom {
border: none;
max-width: 1024px;
width: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}
<header id="top">
<div class="row">
<div class="small-12 small-centered columns">
<img class="headimg" src="http://assets.tumblr.com/images/x.gif?v=1">
<a href="/" class="active">
<div class="title">Page Title</div>
</a>
<div class="description"></div>
<nav>
<a class="page" href="/online-store">Shop NAO</a><a class="page" href="/nao-couture">NAO Couture</a><a class="page" href="/nao-experience">NAO Experience</a>
</nav>
</div>
<!--.columns-->
</div>
<!--.row-->
</header>
I've got a basic layout that is a div with a thumbnail, floated left, then a div with some text in it (title, description, links) that floats lefts as well. They're meant to be side-by-side but as soon as the browser is too narrow, it pushes the 2nd div below the first, rather than just decreasing its width.
I can't believe I'm stumped on this as it seems really simple. I'd really appreciate some help!
html
<div class="stunting-video odd">
<div class="thumbnail">
<img src="https://i.ytimg.com/vi/LixKwLQiSGU/mqdefault.jpg" data-video-id="LixKwLQiSGU" class="show-video" alt="stunting video">
</div>
<div class="info">
<p class="title">GTA V - Stunt practise 03</p>
<p class="description">A play-through of a race created to practise a motorbike stunt in GTA V where you can jump from the docks to near the airport. Race is available here...<br>
<br>
<span class="highlight">PS3:</span> http://rsg.ms/0330f82<br>
<span class="highlight">Xbox360:</span> http://rsg.ms/4464ca5<br>
<br>
Special credits to Cheddar for the 360 version.</p>
</div>
</div>
css
body {
background-color: rgb(20, 20, 20);
color: rgb(238, 238, 221);
font-family: sans-serif;
font-size: 16px;
font-weight: 300;
margin: 20px;
}
a {
color: rgb(111, 178, 244);
}
.stunting-video {
background-color: rgba(255, 255, 255, 0.125);
border-radius: 30px;
box-shadow: 5px 5px 10px rgba(255, 255, 255, 0.3) inset, -5px -5px 10px rgba(0, 0, 0, 0.9) inset;
clear: both;
margin: 10px 0;
overflow: auto;
padding: 5px 15px 15px;
}
.stunting-video .thumbnail {
border: 0;
cursor: pointer;
float: left;
margin: 10px 20px 0 0;
padding: 0;
}
.stunting-video .thumbnail img {
border-radius: 15px 0 0 15px;
}
.stunting-video .info {
float: left;
}
.stunting-video .title {
color: rgb(245, 215, 122);
font-size: 150%;
font-weight: bold;
}
.stunting-video p {
margin: 5px 0;
}
js fiddle example of the above
http://jsfiddle.net/yp7f0nz1/
All that is required is to not float the info div and (based on other comments) add adequate padding=left so that the text does not wrap around the thumbnail.
.stunting-video .info {
padding-left: 350px;;
}
Jsfiddle Demo
EDIT
I was reminded that a table would do this automatically and. of course, we have display:table / table-cell open to us.
Removing the floats and using
.stunting-video {
display: table;
}
and
.stunting-video .thumbnail {
display: table-cell;
vertical-align: top;
}
.stunting-video .info {
display: table-cell;
vertical-align: top;
}
JSfiddle Demo 2