Vuejs - Svgs partially missing once a third is added - css

Not really sure how to ask this question to be honest, but recently I've started using VueJS and it's incredible!
That being said, with all the learning of Vue, I perhaps have lost a bit of my CSS skills; particularly when it comes to flex. I don't recall ever having this issue previously, but once I added a third SVG to my page, the two previous almost completely disappear, but the newest is fully visible.
Any ideas of what the heck could actually be happening here?
I'm not using SVG loader or anything, but rather a v-else-if to show svgs based on names; perhaps that's the issue? (though if that were, the two previously shown were fine until I added the third.)
Cheers!
NOTE: I'm not adding the SVG code, since I didn't want to have too much code showing in this question, but it's a simple hamburger menu svg, a search svg and the top nav stuff for an iphone.
App.vue
<template>
<div id="app">
<div class="container">
<top-nav-bar></top-nav-bar>
</div>
</div>
</template>
<script>
import TopNavBar from './components/molecules/TopNavBar.vue'
export default {
name: 'App',
components: { TopNavBar },
}
</script>
<style lang="sass">
#app
font-family: Avenir, Helvetica, Arial, sans-serif
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
text-align: center
color: #2c3e50
.container
position: relative
margin: 0 auto
border: 2px solid black
background-color: white
border-radius: 40px
width: 414px
height: 896px
</style>
Component:
<template>
<div class="container">
<icons name="nav-info" />
<icons name="hamburger" />
<icons name="search" />
</div>
</template>
<script>
import Icons from '../atoms/Icons.vue'
export default {
components: { Icons },
}
</script>
<style lang="sass" scoped>
.container
display: flex
flex-direction: column
align-items: center
margin: 0
</style>

Related

Text overflow outside of a box, using React and Flexbox

I am having some trouble with the layout in a React web app of mine.
Though it mostly work as I want, here is the situation.
This is the relevant React code:
<React.Fragment>
<div className="container">
<div className="row">
<div className="col-xl-12-w">
<h1 className='blocTit'>{displayTitle}</h1>
</div>
</div>
<div className="row">
<div className="col-xl-12-w">
{clctnBufr.map((item,index) => (
<div
key={item.uid}
className="card float-left"
style={{ width: "18rem", marginRight: "1rem" }}
>
<div className="card-body">
<div className="card-tit-prx">
<div className="card-title">
{displayName(item)}
</div>
<div className="card-price">
{displayPriceC(item.price,this.priceShft,currency)}
</div>
</div>
{displayComment(item)}
</div>
</div>
))}
</div>
</div>
</div>
</React.Fragment>
And this is what I believe to be the relevant css code:
.card-body {
display: flex;
flex-direction: column;
border: 1px solid rgb(117, 61, 5);
background-color: rgb(228, 245, 131);
padding-block: 5px;
}
.card-tit-prx {
display: flex;
flex-direction: row;
align-self: stretch;
justify-content:space-between;
}
.card-title {
color: rgb(52, 8, 155);
font-family: 'Georgia';
font-weight: normal;
font-size: 23px;
padding-left: 2%;
}
.card-price {
color: rgb(185, 73, 28);
font-family: 'Verdana';
font-weight: normal;
font-size: 17px;
padding-right: 2%;
}
The image below is a screenshot showing the issue on the last 3 items where part of the text (namely: "spring onion", "meet") is overflowing outside of the box instead of being inside as the rest of the text.
I have also unsuccessfully tried to reproduce the issue outside of the context. So I wonder if I am not missing something. If someone has an idea on how to further investigate or even better solve this problem I'd be glad.
Here is some more information. By inserting a space in the display of the price (see the 2nd screenshot below) it makes it take 2 lines and the box gets a proper size as consequence. Why it did not get this size when the name (left part) was requiring it is a mystery.
But I do not want to have to insert a space in the display of the price! This is the problem.
I finally solved this issue after spending some time digging.
Just in case somebody happens to read this while hitting a similar case, I report what I did.
The problem of the "card-title" part and the "card-price" part not exhibiting the same behavior for some mysterious reason came from the fact that "card-title" was already defined in a different .css file. The two definitions were conflicting and producing the problem. It was difficult to see at first glance because this other .css file was not directly included and I am not so familiar with the workings of CSS.
A lesson seems to be: "It is not a good idea to define the same css item in two or more different places in a project".

I a using mdi-react package for Icons but when combining it with scss the "font-size" property dosen't work

I am using mdi-react package and combining it with scss to define some styles but the font-size propert is not working.
Everything else (like color property) is working.
I searched it all over the internet but can't find a solution so finally decided to write my first question on stackoverflow.
And I know I can just use size="8rem" in the icon component itself but I don't want to do that because of some reasons.
Here is my Home.js file:
import React from 'react';
import { Helmet } from 'react-helmet';
import CubeOutlineIcon from 'mdi-react/CubeOutlineIcon';
import { Link } from 'react-router-dom';
const home = () => (
<>
<Helmet><title>Quiz App - Home</title></Helmet>
<div id="home">
<section>
<div>
<CubeOutlineIcon className="cube" />
</div>
<h1>Quiz App</h1>
<div className="play-button-container">
<ul>
<li><Link to="/play/instructions">Play</Link></li>
</ul>
</div>
<div className="auth-container">
<Link to="/login">Login</Link>
<Link to="/register">Register</Link>
</div>
</section>
</div>
</>
);
export default home;
Here is my home.scss file:
#home {
background-image: url('../../assets/img/bg1.jpg');
background-size: cover;
background-position: center;
display: flex;
justify-content: space-around;
height: 100vh;
section {
background-color: rgba($color: #000000, $alpha: 0.7);
padding: $normal $md;
height: 80%;
width: 35%;
}
.cube {
font-size: 8rem; //Not working
color: $orange;
}
}
That's because the .cube is actually assigned to an SVG element and that would require you to use height and width to change it's size. Font ain't gonna work hence.
(I'm assuming that you considered it to be a font-icon or so as the color property got applied to it, but it did so cos fill is set as currentColor, which uses the current text-color.)
According to docs, to change the size of the icon you should use the size property.
Check the following link:
https://github.com/levrik/mdi-react#usage

How to overwrite the vue-bootstrap styles in b-modal

I tried to change the background-color in b-modal -> in .modal-header using bootstrap-vue. But the vue doesn't see my styles and I don know why :/
here is the code. I follow by answer in link
HTML:
b-modal(id="card-1" title="CARTÃO DE CRÉDITO" :modal-class="myclass" header-text-variant="light")
VUE
export default {
data: {
myclass: ['myclass']
},
}
CSS
.myclass > .modal-dialog > .modal-content > .modal-header {
background-color: #da2228 !important;
color: white;
}
But I still doesn't see the results. Modal header is white. Any ideas why?
You're probably using a scoped style tag in your .vue file.
If you are, then you need to use a deep-selector to properly target the subcomponent.
The selectors are /deep/, >>> or ::v-deep.
In the below example i use /deep/, but the others should work for you as well.
You can also use the header-class prop on b-modal to directly add the class to the header if you wish.
<template>
<b-modal header-class="my-class">
<template #modal-header>Header</template>
Hello
</b-modal>
<b-modal modal-class="my-second-class">
<template #modal-header>Header</template>
Hello
</b-modal>
</template>
<style scoped>
/deep/ .my-class {
background: black;
color: white;
}
/deep/ .my-second-class > .modal-dialog > .modal-content > .modal-header {
background: black;
color: white;
}
</style>
You can use content-class="your-class" in the vue bootstrap modal.
<b-modal id="myModal" content-class="your-class" title="BootstrapVue">
Body Content
</b-modal>
Or else it is difficult to style the modal cuz the normal class="" does not apply to the code.

CSS simple lines don't work

I'm using Bootstrap CDN. From the 3 rules, the last 2 ones don't work. Neither the image is resized nor the heading change its font color.
HTML
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Custom styles -->
<link rel="stylesheet" type="text/css" href="./stylesheets/portada.css">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="section1">
<h2 class="text-center">Heading</h2>
<img class="img-responsive" src="./images/8.jpg">
</div>
</div>
</div>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>
</html>
CSS
.section1 { // Working
background-color: #363b48;
color: blue;
height: 100px;
}
.section1 .text-center{ // Not working
color: #985475;
margin-top: 20px;
background-color: red;
}
.section1 img{ //Not working
width:20px;
}
Try this, although what you have should work also
.section1 h2{
color: #985475;
margin-top: 20px;
background-color: red;
}
I noticed 2 issues in your code.
First the CDN should not be loaded over http, but https. For
cross domain issues when loading it it's better to use just the //
without the http or https. That way it will load without giving crossdomain issues.
For instance: <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
Second is that you are using comments which should be /* */
instead of // single slashes because they are on the same line with
some CSS code.
Look after fixing these how it looks:
.section1 { /* Working*/
background-color: #363b48;
color: blue;
height: 100px;
}
.section1 .text-center{ /* Working*/
color: #985475;
margin-top: 20px;
background-color: red;
}
.section1 img{ /* Working*/
width:20px;
}
DEMO
http://jsfiddle.net/a_incarnati/undmcszz/9/
I can't tell for sure, but I would bet the problem lies in portada.css as it is (presumably) available on your local env, but not on the online code editors.
Css rules have weight depending on specificity. Even when you supply new rules on top of older ones, the weightiest rule will be applied. See this site to help calculate specificity: http://specificity.keegan.st/
Your HTML should has the next code at the first lines:
<!DOCTYPE html>
<html>
<head>

Polymer background-color of host element

I'm using Polymer for a new version of my website and I'm having some issues with displaying a data-bound background-color in all browsers.
Here is a live example. In Chrome it works as one would expect, with a red background-color showing up (depicted in the image below)
Now, in Firefox and IE 11 the background-color does not show up, resulting in something like this:
Now, I expect this has something to do with the polyfill, since Chrome is the only browser to natively support custom elements as shown in the browser compatibility page
Here's my code (same as in live example):
<polymer-element name="leiding-card" attributes="bgColor">
<template>
<style>
:host{
display: block;
position: relative;
padding: 20px;
border-radius: 2px;
background-color: {{bgColor}};
}
.profilePic{
width: 50px;
height: 50px;
border-radius: 25px;
margin: 10px;
background-size: 50px 50px;
}
</style>
<link rel="stylesheet" href="default_styles.css">
<paper-shadow z="1" animated="true"></paper-shadow>
<div class="white">
<content select="h1"></content>
<template repeat="{{p in people}}">
<div layout horizontal wrap around-justfied>
<div class="profilePic" center style="background-image: url({{p.profilePic}});"></div>
<div style="margin-right: 10px;">
<p>{{p.name}} {{p.lastname}}</p>
<h4>{{p.email}}</h4>
</div>
</div>
</template>
</div>
</template>
<script>
Polymer('leiding-card',{
ready: function(){
this.people = [
{name: "John", lastname: "Snow", profilePic: "http://lorempixel.com/output/cats-q-c-640-480-3.jpg", email: "john.snow#john.snow"},
{name: "Other", lastname: "Bastard", profilePic: "http://lorempixel.com/output/cats-q-c-640-480-8.jpg", email: "other.bastard#other.bastard"}
]
}
});
</script>
</polymer-element>
I've already tried doing stuff like polyfill-next-selector { content: ':host'; }, but I can't really find an example of it online and usually I don't see any issues with directly applying styles to the :host.
There's an open bug around bindings not working in style tags under the polyfill - https://github.com/Polymer/polymer/issues/270. Looks like there's a workaround provided in the bug notes, see http://jsbin.com/pelon/1/edit

Resources