Posts

Showing posts with the label css

center elements within a polygon div container

center elements within a polygon div container currently I have a div container with text in it. div { height: 200px; background: red; } p { text-align: center; } <div> <p> Text goes here </p> </div> and I want this div container being a parallelogram with a vertically centered text in it. div { height: 200px; background: red; clip-path: polygon(0 25%, 100% 0, 100% 25%, 0 50%); } p { text-align: center; } <div> <p> Text goes here </p> </div> as you can see here, the text completely disappears because the css only works for the div container. How can I make the text appear in the vertical center of this parallelogram? Edit: I don't know if using clip-path: polygon(0 25%, 100% 0, 100% 25%, 0 50%); is the best way to create a div container that is skew. 1 Answer 1 Use gradient to create the shape as background and you sim...

How to link my external style sheet?

How to link my external style sheet? <html> <head> <link rel="stylesheet" type="text/css" href="css.css"> - external stylesheet <div class = "idiot" href = "css.css">Purchase!</div> <title></title> </head> <body> </body> <style type="text/css"> .idiot { cursor:pointer; } .idiot:link { color: gray; } .idiot:visited { color: red; } .idiot:hover { color: black; } .idiot:active { color: blue; } </style> </html> Under here is what is written in the external stylesheet- body { background-color:black; } So, I click on the link, but nothing pops up, and nothing even happens at all. You cannot set a href attribute for a div. Either try <a href="css.css"><div class = "idiot">Purchase!</div></a> ...

Problems Importing Bootstrap Studio Renders into React with reactstrap

Problems Importing Bootstrap Studio Renders into React with reactstrap I'm working on a project where the designer is working with BootStrap studio, which exports to html with BootStrap 4, and I'm converting the exported file into React components with reactstrap. I'm facing problems with class and styling rules, since the original file inherit from 7 different files. What's the best way to convert something like: <div id="nav-bars"> <nav class="navbar navbar-light navbar-expand-md" id="top-nav" style="background-color:rgba(0,0,0,0.5);color:rgb(255,255,255);"> <div class="container-fluid"><a class="navbar-brand" href="#" style="background-image:url(&quot;assets/img/logoalt copy.png&quot;);padding-right:5px;background-size:contain;margin-right:0;padding-left:5px;background-position:center;">&nbsp; &nbsp; &nbsp; &nbsp...

Centered owl-carousel where each image has the same hight and keeps its aspect ratio

Centered owl-carousel where each image has the same hight and keeps its aspect ratio Is there an approach to to create a centered owl-carousel where each image has the same height without losing its aspect ratio? owl-carousel I tried to calculate the image sizes with JS/jQuery but then the calculation of the owl-carousel gets messed up. Same result with CSS s. example (jsfiddle): JS/jQuery owl-carousel CSS $(document).ready(function () { $('.loop').owlCarousel({ center: true, items: 3, loop: true, margin: 20 }); }); .owl-carousel .owl-stage { height: 150px; } .owl-carousel .owl-item { height: 100%; } .owl-carousel .owl-item .item { height: 100%; } .owl-carousel .owl-item img { height: 100% !important; width: auto !important; margin: 0 auto; } <link rel="stylesheet" type="text/css" href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.carousel.min.css"> <...

Position 2 headers in the middle of 2 panel

Position 2 headers in the middle of 2 panel I have this code below that consists of 2 panels and 2 header what i'm trying to accomplish is to put the total fruits header in the middle of the left panel and the other header on the right. But whenever i try to put them in the centre it just messes up the whole thing is there a correct way to do this because i'm not sure how to go about it any suggestion would be greatly appreciated. total fruits var redpill = {}; var greenpill = {}; var randompill = {}; var key = "Red Fruits"; redpill[key] = ['Apple', 'Cherry', 'Strawberry', 'Pomegranate', 'Rassberry', 'Watermelon', 'Durian', 'Avacado', 'Lime', 'Honeydew', 'Watermelon','Apple', 'Cherry', 'Strawberry', 'Pomegranate']; var key2 = "Green Fruits"; greenpill[key2] = ['Watermelon', 'Durian', 'Avacado', 'Lime', '...

Fixed element Y position calculated wrong after scroll on chrome for android

Image
Fixed element Y position calculated wrong after scroll on chrome for android Happens when address bar becomes hidden/visible. The element marked on the DOM explorer is the same element shown on the bottom of the screen (with the "Start Planning" button). After scroll it's actual location is being scrolled up (even though it is in fixed position), but no re-rendering occurs since it is still displayed on the screen in the correct position. The interesting thing is that the element does not respond to clicks in the displayed area but rather in the DOM calculated area (aka, if you click above the button it works but not when you click on the button itself). Here is the link the page on our platform that has the issue: https://in-office.wekudo.com/wellness/category/nutrition/smoothie-bar Same issue exists also on Airbnb's platform: https://www.airbnb.com/rooms/select/17017021?search_id=74b85b09-c47b-4d33-854a-c42ffa1d7779&federated_search_id=93685a2b-81cc-49a4-9699-2e...

Get image alt, add as parent class

Get image alt, add as parent class I'm doing some CSS and I'm not great with JavaScript. However I'm not allowed to edit any of the plugin files, so I thought I could use some JavaScript to solve my issue of missing unique classes. I just want to take the alt="" HTML attribute from an image and apply it as class="" HTML attribute to its parent <a> element. alt="" class="" <a> So instead of: <div class="wrapper-class"> <a class="img-parent"> <img alt="image 1" src=""> </a> <a class="img-parent"> <img alt="image 2" src=""> </a> <a class="img-parent"> <img alt="image 3" src=""> </a> </div> I need: <div class="wrapper-class"> <a class="img-parent image-1"> ...

Responsive, cover-fit image tagging

Responsive, cover-fit image tagging I am working on a project where I have a slideshow with images as follows: img { width:100vw; height:100vh; object-fit:cover; } This makes the images fullscreen and behave like background-size:cover, so they fill out the whole viewport on any screen size without distortion. I would like to tag certain points with text tooltips on these images. For this purpose I have found Tim Severien's Taggd, which works great on responsive images, but in my case the object-fit:cover; property makes the tagged positions inaccurate. object-fit:cover; I have tried everything from CSS hacks to improving Tim's code, but I am out of ideas. If you have any solution or workaround in mind please share. Thank you! 2 Answers 2 well i actually wanted to do the same thing. here is what i've done. maybe it will help someone in the future. it would be great if this fe...

elements with background-attachment: fixed don't behave same on mobile as on desktop

elements with background-attachment: fixed don't behave same on mobile as on desktop Seems like this issue is known for few years already. I tried to apply blurred background to inside elements with class " .blurred-bg " as per this example https://codepen.io/ariona/pen/geFIK . It has one clear-version image applied as background of body element and blurred-version of same image is applied to elements with class .blurred-bg . .blurred-bg .blurred-bg Here is my code do you know, what can I try to make it work? <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>blurred background sablona</title> <style> body { margin: 0px; padding: 0px; background-image: url("https://lh4.googleusercontent.com/-3eBjuQpOGFw/U47yh_-OycI/AAAAAAAAI2U/uaU5pK49N1w/s1600/normal.jpg"); background-repeat: no-repe...

How do I change this fill gradient from bottom to top

How do I change this fill gradient from bottom to top <svg width="100" height="50" version="1.1" xmlns="http://www.w3.org/2000/svg"> <style type="text/css"> rect{fill:url(#MyGradient)} </style> <defs> <linearGradient id="MyGradient"> <stop offset="5%" stop-color="#F60" /> <stop offset="95%" stop-color="#FF6" /> </linearGradient> </defs> <rect width="100" height="50"> </svg> I want #F60 to be the bottom and #FF6 to be the top and i dont want to rotate it .. I never worked with svg but, can't you just switch the 'stop' lines? – M. Gara Jul 1 at 5:38 ...

How to make content wrapper “on top” of css grid

How to make content wrapper “on top” of css grid I'm working on a site layout using a two-column CSS grid, which looks somewhat like this. It works fine and all the content centers perfectly in each div. The cells with "bg" just have a background image. Each grid cell "touches" the borders of the browser window. +--------+--------+ | text | bg | +--------+--------+ | bg | text | +--------+--------+ | text | +-----------------+ However, is there an easy way to wrap & center the content so that it doesn't go beyond a certain width? I could target individual paragraphs to align left or right depending on their cells, but I was wondering if there's a more elegant way to do this? The brackets are the "wrapper". +--------+--------+ | [text| bg] | +--------+--------+ | [bg |text] | +--------+--------+ | [ text ] | +-----------------+ Please post the code you have tried. ...

Edge browser menu item hover glitch

Edge browser menu item hover glitch Been battling with this for a few days - finally caving in and asking for help. I'm experiencing a super weird issue in the Edge browser. Here's the test site: http://edge22.com/test-edge/ When you hover over the menu items, a 1px line appears below the menu item you hovered. There's no border, text-decoration etc.. If the white header area is made black, the line is black etc.. It's like the height of the menu item is reducing by 1px only on hover: http://screencast.com/t/Lpkow3HF0 Now the weird part. This only happens when the element right before the navigation is a link (the "Test" link). If this link is removed, the glitch disappears. Now if I wrap the link in a div and give it a small margin, the issue goes away: <div style="margin-bottom:0.1em;"><a href="#">Link</a></div> Does anyone have any idea what's going on? I've stripped all of the CSS down to nothing, and can...

Place a background image just below the navbar bootstrap-4 Beta

Place a background image just below the navbar bootstrap-4 Beta I want to place a background image just below the navbar with full height . If I remove Bootstrap class fixed-top then background image automatically start below the navbar. In this situation what should I do? How can I achieve this task? fixed-top header#MyHeaderControl{ height: 100vh; width: 100%; background-image:url("https://images.pexels.com/photos/1055297/pexels-photo-1055297.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"); background-repeat: no-repeat; background-position: center center; background-size: cover; -webkit-background-size: cover; -moz-background-size:cover; -o-background-size:cover; } <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <script src="htt...

HTML Split SINGLE BACKGROUND IMAGE into two equal links (top and bottom)

HTML Split SINGLE BACKGROUND IMAGE into two equal links (top and bottom) I am just learning HTML. Is there a way without using image mapping to split a background image into 50-50%, with each half linking to an external link? I put style=0% and 50% to split the links into the top 50% and bottom 50%, but it doesn't split the image in two. This is what I have: <!DOCTYPE html> <html> <head> <title>Page 2</title> <link href="https://fonts.googleapis.com/css?family=Proxima+Nova" rel="stylesheet"> </head> <body> <div class="image"> <center><img src="{% static 'picture.png' %}" alt="image" /></center> <a href="link1" style="top: 0%;"></a> <a href="link2" style="top: 50%;"></a> </div> </body> </html> Thanks in advance! Use an imag...

jquery filtering not floating left with category selected

jquery filtering not floating left with category selected I am brand new to learning about jQuery. I started with a youtube tutorial (which is a couple years old so I'm sure its a little out of date) and followed it to the tee but when I select one of my cateogry tabs the images disapear but the pictures that remain do not float to the left. My question is what am I miss so the the category images float left when they are selected? Here is my jsfiddle for my code. $(document).ready(function(){ $('.category_item').click(function(){ var category = $(this).attr('id'); if(category == 'all'){ $('.icon').addClass('hide'); setTimeout(function(){ $('.icon').removeClass('hide'); }, 300); } else { $('.icon').addClass('hide'); setTimeout(function(){ $('.' + category).removeClass('hide'); }, 300); } }); }); PS: It's ...

Tree shaking css using angular-cli build / schemantics

Tree shaking css using angular-cli build / schemantics I am on an angular-cli project. I am facing an issue with the css. This is somewhat a non-code question and deviates from stackoverflow needs of putting code. But hopefully it will not be marked down for closure. Here is the background: I have a lot of unnecessary css lingering around. I need treeshaking for the unnecessary css during the build process. Is there one that you can help me with. Here is the background of what is happening: Options: I see manual tree shaking is an issue. So I saw there are a few css treeshakers around but since angular cli works with multiple components, I see a need of cli integration of the css tree shaker. I could not find one for cli to merge with build. Questions: Anyone has suggestion on how to integrate or is there a css-tree shaker community project? I have not worked with schmatics. What exactly do you mean by treeshaking unnecessary CSS? Could you provide a generic...